From 1b38e41eec9da0d06d6cfe18087c16cc9e12afac Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Thu, 6 May 2021 15:34:09 +0300 Subject: [PATCH 1/3] fixup! at long last, reformat all Python code with 2 space indents --- nvim/after/ftplugin/python.vim | 1 - 1 file changed, 1 deletion(-) delete mode 100644 nvim/after/ftplugin/python.vim diff --git a/nvim/after/ftplugin/python.vim b/nvim/after/ftplugin/python.vim deleted file mode 100644 index e10ab03..0000000 --- a/nvim/after/ftplugin/python.vim +++ /dev/null @@ -1 +0,0 @@ -Indent 4 From 50440e632a0afdc878356ad6dc801b21f1094905 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sat, 8 May 2021 15:53:40 +0300 Subject: [PATCH 2/3] [web] add my userscripts --- {mozilla => web}/firefox/userContent.css | 0 web/userscripts/README.md | 1 + .../github-icon-vertical-align.user.js | 32 +++++++++++++++++ web/userscripts/github-line-height.user.js | 34 +++++++++++++++++++ web/userscripts/github-tab-size.user.js | 34 +++++++++++++++++++ .../steamcommunity-com-linkfilter.user.js | 16 +++++++++ .../twitter-s-param-remover.user.js | 17 ++++++++++ web/userscripts/youtube-screenshot.user.js | 30 ++++++++++++++++ 8 files changed, 164 insertions(+) rename {mozilla => web}/firefox/userContent.css (100%) create mode 100644 web/userscripts/README.md create mode 100644 web/userscripts/github-icon-vertical-align.user.js create mode 100644 web/userscripts/github-line-height.user.js create mode 100644 web/userscripts/github-tab-size.user.js create mode 100644 web/userscripts/steamcommunity-com-linkfilter.user.js create mode 100644 web/userscripts/twitter-s-param-remover.user.js create mode 100644 web/userscripts/youtube-screenshot.user.js diff --git a/mozilla/firefox/userContent.css b/web/firefox/userContent.css similarity index 100% rename from mozilla/firefox/userContent.css rename to web/firefox/userContent.css diff --git a/web/userscripts/README.md b/web/userscripts/README.md new file mode 100644 index 0000000..c118d98 --- /dev/null +++ b/web/userscripts/README.md @@ -0,0 +1 @@ +[Tampermonkey](https://www.tampermonkey.net/) ([Firefox extension](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/), [Chrome extension](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)) is recommended for loading these as it supports installing and updating userscripts from a remote URL. diff --git a/web/userscripts/github-icon-vertical-align.user.js b/web/userscripts/github-icon-vertical-align.user.js new file mode 100644 index 0000000..69a94b1 --- /dev/null +++ b/web/userscripts/github-icon-vertical-align.user.js @@ -0,0 +1,32 @@ +// ==UserScript== +// @name GitHub icon vertical alignment fix +// @version 1 +// @grant none +// @match https://github.com/* +// @match https://gist.github.com/* +// @run-at document-start +// ==/UserScript== + +(() => { + 'use strict'; + + 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(); + }); + } +})(); diff --git a/web/userscripts/github-line-height.user.js b/web/userscripts/github-line-height.user.js new file mode 100644 index 0000000..fa0a9e5 --- /dev/null +++ b/web/userscripts/github-line-height.user.js @@ -0,0 +1,34 @@ +// ==UserScript== +// @name GitHub line-height +// @version 1 +// @grant none +// @match https://github.com/* +// @match https://gist.github.com/* +// @run-at document-start +// ==/UserScript== + +(() => { + 'use strict'; + + const LINE_HEIGHT = '1.2'; + + 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(); + }); + } +})(); diff --git a/web/userscripts/github-tab-size.user.js b/web/userscripts/github-tab-size.user.js new file mode 100644 index 0000000..12e5fad --- /dev/null +++ b/web/userscripts/github-tab-size.user.js @@ -0,0 +1,34 @@ +// ==UserScript== +// @name GitHub tab size 4 +// @version 1 +// @grant none +// @match https://github.com/* +// @match https://gist.github.com/* +// @run-at document-start +// ==/UserScript== + +(() => { + 'use strict'; + + const TAB_SIZE = '4'; + + 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(); + }); + } +})(); diff --git a/web/userscripts/steamcommunity-com-linkfilter.user.js b/web/userscripts/steamcommunity-com-linkfilter.user.js new file mode 100644 index 0000000..324e011 --- /dev/null +++ b/web/userscripts/steamcommunity-com-linkfilter.user.js @@ -0,0 +1,16 @@ +// ==UserScript== +// @name steamcommunity.com linkfilter disabler +// @version 1 +// @grant none +// @run-at document-start +// @match https://steamcommunity.com/linkfilter/* +// ==/UserScript== + +(() => { + 'use strict'; + let searchParams = new URLSearchParams(window.location.search); + let url = searchParams.get('url'); + if (url) { + window.location.replace(url); + } +})(); diff --git a/web/userscripts/twitter-s-param-remover.user.js b/web/userscripts/twitter-s-param-remover.user.js new file mode 100644 index 0000000..42fb6bd --- /dev/null +++ b/web/userscripts/twitter-s-param-remover.user.js @@ -0,0 +1,17 @@ +// ==UserScript== +// @name twitter ?s=20 remover +// @version 1 +// @grant none +// @match https://twitter.com/* +// @run-at document-start +// ==/UserScript== + +(() => { + 'use strict'; + let searchParams = new URLSearchParams(window.location.search); + let strangeValue = searchParams.get('s'); + if (/[0-9]+/.test(strangeValue)) { + searchParams.delete('s'); + window.location.search = searchParams.toString(); + } +})(); diff --git a/web/userscripts/youtube-screenshot.user.js b/web/userscripts/youtube-screenshot.user.js new file mode 100644 index 0000000..cb5e191 --- /dev/null +++ b/web/userscripts/youtube-screenshot.user.js @@ -0,0 +1,30 @@ +// ==UserScript== +// @name YouTube screenshotter +// @version 1 +// @grant none +// @match https://www.youtube.com/* +// @run-at document-end +// ==/UserScript== + +(() => { + 'use strict'; + + function main() { + window.__userscript__takeScreenshot = function (video, imageType = 'image/png') { + if (!(video instanceof HTMLVideoElement)) { + throw new Error('Assertion failed: video instanceof HTMLVideoElement'); + } + + let canvas = document.createElement('canvas'); + canvas.width = video.videoWidth; + canvas.height = video.videoHeight; + let ctx = canvas.getContext('2d'); + ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); + window.open(canvas.toDataURL(imageType), '_blank'); + }; + } + + let script = document.createElement('script'); + script.append('(' + main + ')();'); + (document.body || document.head || document.documentElement).appendChild(script); +})(); From 92361f9a54ee77a02f8826f0c2ea125f1f5be18e Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sat, 8 May 2021 16:21:27 +0300 Subject: [PATCH 3/3] [userscripts] use the available helper functions --- .../github-icon-vertical-align.user.js | 29 +++++------------ web/userscripts/github-line-height.user.js | 31 +++++-------------- web/userscripts/github-tab-size.user.js | 31 +++++-------------- web/userscripts/youtube-screenshot.user.js | 10 +++--- 4 files changed, 28 insertions(+), 73 deletions(-) diff --git a/web/userscripts/github-icon-vertical-align.user.js b/web/userscripts/github-icon-vertical-align.user.js index 69a94b1..eb24152 100644 --- a/web/userscripts/github-icon-vertical-align.user.js +++ b/web/userscripts/github-icon-vertical-align.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name GitHub icon vertical alignment fix -// @version 1 -// @grant none +// @version 2 +// @grant GM_addStyle // @match https://github.com/* // @match https://gist.github.com/* // @run-at document-start @@ -9,24 +9,9 @@ (() => { 'use strict'; - - 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(); - }); - } + GM_addStyle(` + .btn-sm .octicon { + vertical-align: middle; + } + `); })(); diff --git a/web/userscripts/github-line-height.user.js b/web/userscripts/github-line-height.user.js index fa0a9e5..70b1aca 100644 --- a/web/userscripts/github-line-height.user.js +++ b/web/userscripts/github-line-height.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name GitHub line-height -// @version 1 -// @grant none +// @version 2 +// @grant GM_addStyle // @match https://github.com/* // @match https://gist.github.com/* // @run-at document-start @@ -9,26 +9,11 @@ (() => { 'use strict'; - const LINE_HEIGHT = '1.2'; - - 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(); - }); - } + 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}; + } + `); })(); diff --git a/web/userscripts/github-tab-size.user.js b/web/userscripts/github-tab-size.user.js index 12e5fad..1dd581b 100644 --- a/web/userscripts/github-tab-size.user.js +++ b/web/userscripts/github-tab-size.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name GitHub tab size 4 -// @version 1 -// @grant none +// @version 2 +// @grant GM_addStyle // @match https://github.com/* // @match https://gist.github.com/* // @run-at document-start @@ -9,26 +9,11 @@ (() => { 'use strict'; - const TAB_SIZE = '4'; - - 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(); - }); - } + GM_addStyle(` + * { + -moz-tab-size: ${TAB_SIZE} !important; + tab-size: ${TAB_SIZE} !important; + } + `); })(); diff --git a/web/userscripts/youtube-screenshot.user.js b/web/userscripts/youtube-screenshot.user.js index cb5e191..e2c2f29 100644 --- a/web/userscripts/youtube-screenshot.user.js +++ b/web/userscripts/youtube-screenshot.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name YouTube screenshotter -// @version 1 -// @grant none +// @version 2 +// @grant GM_addElement // @match https://www.youtube.com/* // @run-at document-end // ==/UserScript== @@ -24,7 +24,7 @@ }; } - let script = document.createElement('script'); - script.append('(' + main + ')();'); - (document.body || document.head || document.documentElement).appendChild(script); + GM_addElement('script', { + textContent: `(${main.toString()})();`, + }); })();