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==
// @name GitHub icon vertical alignment fix
// @version 2
// @grant GM_addStyle
// @version 3
// @grant none
// @match https://github.com/*
// @match https://gist.github.com/*
// @run-at document-start
@ -9,9 +9,24 @@
(() => {
'use strict';
GM_addStyle(`
.btn-sm .octicon {
vertical-align: middle;
}
`);
function addStylesheet() {
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==
// @name GitHub line-height
// @version 2
// @grant GM_addStyle
// @version 3
// @grant none
// @match https://github.com/*
// @match https://gist.github.com/*
// @run-at document-start
@ -9,11 +9,26 @@
(() => {
'use strict';
const LINE_HEIGHT = '1.2';
GM_addStyle(`
.blob-num, .blob-code, .markdown-body .highlight pre, .markdown-body pre,
.cm-s-github-light .CodeMirror-lines, textarea.file-editor-textarea {
line-height: ${LINE_HEIGHT};
}
`);
function addStylesheet() {
let style = document.createElement('style');
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==
// @name GitHub tab size 4
// @version 2
// @grant GM_addStyle
// @version 3
// @grant none
// @match https://github.com/*
// @match https://gist.github.com/*
// @run-at document-start
@ -9,11 +9,26 @@
(() => {
'use strict';
const TAB_SIZE = '4';
GM_addStyle(`
* {
-moz-tab-size: ${TAB_SIZE} !important;
tab-size: ${TAB_SIZE} !important;
}
`);
function addStylesheet() {
let style = document.createElement('style');
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==
// @name YouTube screenshotter
// @version 2
// @grant GM_addElement
// @version 3
// @grant none
// @match https://www.youtube.com/*
// @run-at document-end
// ==/UserScript==
@ -24,7 +24,7 @@
};
}
GM_addElement('script', {
textContent: `(${main.toString()})();`,
});
let script = document.createElement('script');
script.append(`(${main.toString()})();`);
(document.body || document.head || document.documentElement).appendChild(script);
})();