Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the css rule "body overflow:hidden" automatically

In some web pages entering with adblock installed is added in the body the "overflow:hidden" css style, preventing the scroll of a website.

Example:

<html>
  <head>
      <title>Website</title>
  </head>
  <body style="overflow: hidden;">
    Some long article content
  </body>
</html>

I have to manually edit in Chrome web inspector to remove each time, which is annoying.

I would like know I could make this removal permanent or detect via a chrome extension or adblock rule to remove it or maybe via a direct javascript, etc.

UPDATE: Using tampermonkey chrome extension, probably I could reach my goal. I did the following script without result (the page seems reload or load some javascript and I cannot remove properly the body overflow hidden):

// ==UserScript==
// @name         InvestingRemoveScrollBodyBlocker
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Remove body overflow hidden
// @author       Ángel Guzmán Maeso <[email protected]>
// @match        https://*.investing.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    setTimeout(function(){

        var bodyWeb = document.getElementsByTagName("BODY")[0];
        console.log(bodyWeb);
        bodyWeb.style.overflow = "visible !important";

    }, 4000);

})();
like image 787
shakaran Avatar asked Jul 13 '18 17:07

shakaran


2 Answers

You can add a uBlock Origin filter rule with a :style() operator to override this:

*##html,body:style(overflow: visible !important;)
like image 62
Martin Valgur Avatar answered Sep 19 '22 03:09

Martin Valgur


Try this script tool TamperMonkey

To override overflow

body {
   overflow: visible !important;
}

The script that will work with TamperMonkey:

// ==UserScript==
// @name         InvestingRemoveScrollBodyBlocker
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Remove body overflow hidden
// @author       Ángel Guzmán Maeso <[email protected]>
// @match        https://*.investing.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // Credits: https://stackoverflow.com/questions/51330252/how-to-remove-the-css-rule-body-overflowhidden-automatically
    document.body.style.cssText = "visible !important";
})();
like image 42
Irina Avatar answered Sep 19 '22 03:09

Irina