Last active
April 27, 2025 02:42
-
-
Save Erquint/051e173afc07440050ac04c493d4c8d1 to your computer and use it in GitHub Desktop.
For those pesky websites that disable scrolling. Fiend mode button available in the popup if you dare. Install using the following link: https://gist.githubusercontent.com/Erquint/051e173afc07440050ac04c493d4c8d1/raw/scrollfiend.user.js
This file contains hidden or 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 Scrollfiend | |
// @description Enables scrolling on those pesky websites that disable it. | |
// @version 2.0.0 | |
// @namespace [email protected] | |
// @author https://gist.github.com/Erquint | |
// @homepageURL https://gist.github.com/Erquint/051e173afc07440050ac04c493d4c8d1 | |
// @updateURL https://gist.githubusercontent.com/Erquint/051e173afc07440050ac04c493d4c8d1/raw/scrollfiend.user.js | |
// @downloadURL https://gist.githubusercontent.com/Erquint/051e173afc07440050ac04c493d4c8d1/raw/scrollfiend.user.js | |
// @match *://*/* | |
// @grant GM_addStyle | |
// @grant GM_registerMenuCommand | |
// @run-at document-idle | |
// ==/UserScript== | |
// StyleSheetList[CSSStyleSheet] sheets = document.styleSheets | |
// CSSRuleList[CSSRule] rules = CSSStyleSheet.cssRules | |
// CSSRuleList[CSSRule] rules = CSSRule.cssRules | |
// CSSStyleDeclaration style = CSSRule.style | |
// | |
// document.styleSheets[0].cssRules[0].style | |
// document.styleSheets[0].cssRules[0].cssRules[0].style | |
function get_all_rules(){ | |
buffer_1 = Array.from(document.styleSheets); | |
while(true){ | |
let buffer_2 = new Array; | |
let sheets_found = false; | |
while(buffer_1.length){ | |
sheet_or_rule = buffer_1.pop(); | |
if(!!sheet_or_rule?.cssRules && !!sheet_or_rule?.cssRules.length){ // Sheet. | |
sheets_found = true; | |
buffer_2.push(...sheet_or_rule.cssRules); | |
}else{ // Rule. | |
buffer_2.push(sheet_or_rule); | |
} | |
} | |
if(sheets_found){ | |
buffer_1 = buffer_2; | |
}else{ // All page rules are in buffer_2. | |
return buffer_2; | |
} | |
} | |
} | |
function rampage(){ | |
const selector_string = ':root, html, body, main, article, *'; | |
const rules_string = 'overflow: unset !important; overflow-x: unset !important; overflow-y: unset !important; position: unset !important;'; | |
rules = get_all_rules(); | |
rules.push(GM_addStyle(`${selector_string} {${rules_string}}`).sheet.cssRules[0]); | |
for(rule of rules){ | |
if(!!rule?.style){ | |
rule.style.overflow = 'unset !important'; | |
rule.style.overflowX = 'unset !important'; | |
rule.style.overflowY = 'unset !important'; | |
rule.style.position = 'unset !important'; | |
rule.style.cssText += `${rules_string}`; | |
for(element of document.querySelectorAll(rule.style.parentRule.selectorText)){ | |
element.style.cssText = `${rules_string}`; | |
} | |
for(eventTarget of [window, document]){ | |
for(eventType of ['wheel', 'keydown']){ | |
eventTarget.addEventListener(eventType, e => event.stopImmediatePropagation(), true); | |
} | |
} | |
} | |
} | |
} | |
let rules; | |
GM_registerMenuCommand('Reinforce!', rampage); | |
rampage(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment