2022-07-01 14:43:46 +00:00
|
|
|
// ==UserScript==
|
|
|
|
// @name RESser
|
|
|
|
// @namespace blankie-scripts
|
|
|
|
// @match https://old.reddit.com/*
|
|
|
|
// @grant GM_openInTab
|
2023-01-06 16:40:41 +00:00
|
|
|
// @version 1.4.1
|
2022-07-01 14:43:46 +00:00
|
|
|
// @author blankie
|
2023-01-06 16:40:41 +00:00
|
|
|
// @inject-into content
|
2022-07-01 14:43:46 +00:00
|
|
|
// @run-at document-start
|
|
|
|
// ==/UserScript==
|
|
|
|
|
|
|
|
document.addEventListener('keydown', function(e) {
|
|
|
|
switch (e.keyCode) {
|
|
|
|
case 86: // v
|
|
|
|
case 78: // n
|
|
|
|
// v/n to expose text spoilers
|
|
|
|
document.querySelectorAll('.RES-keyNav-activeElement .md-spoiler-text:not(.revealed)').forEach((e) => {
|
|
|
|
e.classList.add('revealed');
|
|
|
|
e.click();
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 13: // return/enter
|
|
|
|
// [shift-]enter on crossposted item to go to crossposted item instead of link
|
|
|
|
const crosspostA = document.querySelector('.RES-keyNav-activeElement .crosspost-preview a');
|
|
|
|
if (crosspostA !== null) {
|
|
|
|
e.stopImmediatePropagation();
|
|
|
|
if (e.shiftKey) {
|
|
|
|
// TODO fix duplicate link from res lmao
|
|
|
|
GM_openInTab(crosspostA.href, {active: true});
|
|
|
|
} else {
|
|
|
|
location.href = crosspostA.href;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// shift-enter on 'Continue this thread'
|
|
|
|
if (e.shiftKey) {
|
|
|
|
const continueThing = document.querySelector('.RES-keyNav-activeElement > span.deepthread > a');
|
|
|
|
if (continueThing !== null) {
|
|
|
|
GM_openInTab(continueThing.href, {active: true});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}, {capture: true, useCapture: true})
|