mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[userscripts] add some useless scripts
This commit is contained in:
parent
55cfc18621
commit
0e14982fa3
2 changed files with 52 additions and 0 deletions
17
web/userscripts/github-set-theme-without-login.user.js
Normal file
17
web/userscripts/github-set-theme-without-login.user.js
Normal 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';
|
||||
})();
|
35
web/userscripts/gitlab-set-theme-without-login.user.js
Normal file
35
web/userscripts/gitlab-set-theme-without-login.user.js
Normal 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');
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue