Skip to content

Instantly share code, notes, and snippets.

@RyanHirsch
Last active July 8, 2021 14:50
Show Gist options
  • Save RyanHirsch/88d61d212206630dbeb4c325435600c2 to your computer and use it in GitHub Desktop.
Save RyanHirsch/88d61d212206630dbeb4c325435600c2 to your computer and use it in GitHub Desktop.
republic times
// ==UserScript==
// @name Republic Times Cleanup
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description try to take over the world!
// @author You
// @match https://republictimes.net/*
// @match https://republictimes.net
// @match http://republictimes.net/*
// @grant none
// ==/UserScript==
function removeAllListeners(node, type) {
const listeners = window.getEventListeners(node);
if(Array.isArray(listeners[type])) {
console.log(`Removing ${type} handlers`)
listeners[type].forEach(fn => node.removeEventListener(fn.type, fn.listener))
} else {
console.log(`No ${type} handlers found on the node`, node);
}
if(typeof node[`on${type.toLowerCase()}`] === "function") {
console.log(`Removing on${type.toLowerCase()} handler`)
node[`on${type.toLowerCase()}`] = null;
}
}
(function() {
document.body.classList.remove("unselectable");
removeAllListeners(document, "click");
removeAllListeners(document, "contextmenu");
removeAllListeners(document, "mousedown");
removeAllListeners(document, "selectstart");
removeAllListeners(document.body, "selectstart");
Array.from(document.styleSheets)
.filter(sheet => sheet.href === null)
.find(sheet => Array.from(sheet.rules).some(r => r.selectorText === ".unselectable")).disabled = true;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment