Revert "[userscripts] use the available helper functions"

This reverts commit 92361f9a54.
This commit is contained in:
Dmytro Meleshko 2021-05-08 22:00:21 +03:00
parent 92361f9a54
commit f62f9bc0ba
4 changed files with 73 additions and 28 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name GitHub icon vertical alignment fix // @name GitHub icon vertical alignment fix
// @version 2 // @version 3
// @grant GM_addStyle // @grant none
// @match https://github.com/* // @match https://github.com/*
// @match https://gist.github.com/* // @match https://gist.github.com/*
// @run-at document-start // @run-at document-start
@ -9,9 +9,24 @@
(() => { (() => {
'use strict'; 'use strict';
GM_addStyle(`
.btn-sm .octicon { function addStylesheet() {
vertical-align: middle; let style = document.createElement('style');
} style.append(
`); //
'.btn-sm .octicon {\n',
' vertical-align: middle;\n',
'}\n',
);
document.head.appendChild(style);
}
if (document.readyState !== 'loading') {
addStylesheet();
} else {
document.addEventListener('readystatechange', () => {
if (document.readyState === 'loading') return;
addStylesheet();
});
}
})(); })();

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name GitHub line-height // @name GitHub line-height
// @version 2 // @version 3
// @grant GM_addStyle // @grant none
// @match https://github.com/* // @match https://github.com/*
// @match https://gist.github.com/* // @match https://gist.github.com/*
// @run-at document-start // @run-at document-start
@ -9,11 +9,26 @@
(() => { (() => {
'use strict'; 'use strict';
const LINE_HEIGHT = '1.2'; const LINE_HEIGHT = '1.2';
GM_addStyle(`
.blob-num, .blob-code, .markdown-body .highlight pre, .markdown-body pre, function addStylesheet() {
.cm-s-github-light .CodeMirror-lines, textarea.file-editor-textarea { let style = document.createElement('style');
line-height: ${LINE_HEIGHT}; style.append(
} '.blob-num, .blob-code, .markdown-body .highlight pre, .markdown-body pre, \n',
`); '.cm-s-github-light .CodeMirror-lines, textarea.file-editor-textarea {\n',
` line-height: ${LINE_HEIGHT};\n`,
'}\n',
);
document.head.appendChild(style);
}
if (document.readyState !== 'loading') {
addStylesheet();
} else {
document.addEventListener('readystatechange', () => {
if (document.readyState === 'loading') return;
addStylesheet();
});
}
})(); })();

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name GitHub tab size 4 // @name GitHub tab size 4
// @version 2 // @version 3
// @grant GM_addStyle // @grant none
// @match https://github.com/* // @match https://github.com/*
// @match https://gist.github.com/* // @match https://gist.github.com/*
// @run-at document-start // @run-at document-start
@ -9,11 +9,26 @@
(() => { (() => {
'use strict'; 'use strict';
const TAB_SIZE = '4'; const TAB_SIZE = '4';
GM_addStyle(`
* { function addStylesheet() {
-moz-tab-size: ${TAB_SIZE} !important; let style = document.createElement('style');
tab-size: ${TAB_SIZE} !important; style.append(
} '* {\n',
`); ` -moz-tab-size: ${TAB_SIZE} !important;\n`,
` tab-size: ${TAB_SIZE} !important;\n`,
'}\n',
);
document.head.appendChild(style);
}
if (document.readyState !== 'loading') {
addStylesheet();
} else {
document.addEventListener('readystatechange', () => {
if (document.readyState === 'loading') return;
addStylesheet();
});
}
})(); })();

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name YouTube screenshotter // @name YouTube screenshotter
// @version 2 // @version 3
// @grant GM_addElement // @grant none
// @match https://www.youtube.com/* // @match https://www.youtube.com/*
// @run-at document-end // @run-at document-end
// ==/UserScript== // ==/UserScript==
@ -24,7 +24,7 @@
}; };
} }
GM_addElement('script', { let script = document.createElement('script');
textContent: `(${main.toString()})();`, script.append(`(${main.toString()})();`);
}); (document.body || document.head || document.documentElement).appendChild(script);
})(); })();