[userscripts] add some useless scripts

This commit is contained in:
Dmytro Meleshko 2021-05-30 14:35:15 +03:00
parent 55cfc18621
commit 0e14982fa3
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,17 @@
// ==UserScript==
// @name GitHub set theme without login
// @version 1
// @grant none
// @match https://github.com/*
// @match https://gist.github.com/*
// @run-at document-start
// ==/UserScript==
(() => {
'use strict';
let $html = document.documentElement;
$html.dataset.colorMode = 'dark';
$html.dataset.darkTheme = 'dark_dimmed';
$html.dataset.lightTheme = 'light';
})();

View file

@ -0,0 +1,35 @@
// ==UserScript==
// @name GitLab set theme without login
// @description DOES NOT WORK
// @version 1
// @grant none
// @match https://gitlab.com/*
// @match https://salsa.debian.org/*
// @run-at document-start
// ==/UserScript==
(() => {
'use strict';
for (let $link of document.getElementsByTagName('link')) {
if (!($link.as === 'style' || $link.rel === 'stylesheet')) continue;
let pattern = /^(https:\/\/assets\.gitlab-static\.net\/assets\/)(.+)(-[0-9a-fA-F]{64}\.css)$/;
let matches = $link.href.match(pattern);
if (matches == null) continue;
let [hrefBefore, assetPath, hrefAfter] = matches.slice(1);
let newAssetPath = null;
if (assetPath === 'application' || assetPath === 'application_utilities') {
newAssetPath = `${assetPath}_dark`;
} else if (assetPath === 'highlight/themes/white') {
newAssetPath = 'highlight/themes/dark';
}
if (newAssetPath == null) continue;
$link.href = `${hrefBefore}${newAssetPath}${hrefAfter}`;
}
document.body.classList.remove('ui-indigo');
document.body.classList.add('gl-dark');
})();