43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
|
// ==UserScript==
|
||
|
// @name RESser
|
||
|
// @namespace blankie-scripts
|
||
|
// @match https://old.reddit.com/*
|
||
|
// @grant GM_openInTab
|
||
|
// @version 1.4
|
||
|
// @author blankie
|
||
|
// @inject-into page
|
||
|
// @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})
|