Last active
July 11, 2023 09:52
-
-
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 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. Engage fiend mode with a popup button if you dare. | |
// @version 1.1.0 | |
// @namespace gness.na@gmail.com | |
// @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 | |
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 undisable_scrollbars(){ | |
for(rule of rules){ | |
if(!!rule.style){ | |
rule.style.overflowX = 'unset'; | |
rule.style.overflowY = 'unset'; | |
} | |
} | |
} | |
function fiend_mode(){ | |
for(rule of rules){ | |
if(!!rule.style){ | |
rule.style.overflowX = 'scroll'; | |
rule.style.overflowY = 'scroll'; | |
style = 'html,body,main,*{overflow:unset !important}' | |
} | |
} | |
} | |
let rules = get_all_rules(); | |
undisable_scrollbars(); | |
rules.push(GM_addStyle('html,body,main,*{overflow:unset !important}').sheet.cssRules[0]); | |
GM_registerMenuCommand('Engage fiend mode!', fiend_mode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment