Created
January 23, 2024 23:54
-
-
Save lucaswerkmeister/dae1cbf10bfe486485d3a6e6dd9f6439 to your computer and use it in GitHub Desktop.
Questionable Content user scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Preload Questionable Content | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Preload the next Questionable Content comic image. | |
// @author Lucas Werkmeister | |
// @match https://questionablecontent.net/* | |
// @match https://www.questionablecontent.net/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=questionablecontent.net | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
/** | |
* Add a <link rel=preload> for the next Questionable Content comic image. | |
* (Semantically, I think prefetch would be more correct than preload, | |
* but prefetch didn’t seem to have an effect, | |
* and this is just a private user script anyways.) | |
*/ | |
'use strict'; | |
const url = new URL(document.location); | |
let comic; | |
if (url.pathname === '/view.php' | |
&& (comic = url.searchParams.get('comic')) !== null | |
&& !isNaN(comic = parseInt(comic, 10)) | |
) { | |
const link = document.createElement('link'); | |
link.href = new URL(`/comics/${comic + 1}.png`, url); | |
link.rel = 'preload'; | |
link.as = 'image'; | |
document.head.appendChild(link); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Questionable Content x=random | |
// @namespace http://tampermonkey.net/ | |
// @version 2023-12-12 | |
// @description Make "x" show a random Questionable Content comic (like on SMBC ^^) | |
// @author Lucas Werkmeister | |
// @match https://questionablecontent.net/* | |
// @match https://www.questionablecontent.net/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=questionablecontent.net | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
document.addEventListener('keydown', e => { | |
if (e.key !== 'x' || e.ctrlKey || e.shiftKey || e.altKey) { | |
return; | |
} | |
for (const link of document.querySelectorAll('a[href]')) { | |
if (link.textContent === 'Random') { | |
document.location = link.href; | |
break; | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment