admin管理员组

文章数量:1200397

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    /
// @version      0.1
// @description  Remove body overflow hidden
// @author       Ángel Guzmán Maeso <[email protected]>
// @match        https://*.investing/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    setTimeout(function(){

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

    }, 4000);

})();

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);

})();
Share Improve this question edited Jul 13, 2018 at 22:47 Irina 7841 gold badge12 silver badges26 bronze badges asked Jul 13, 2018 at 17:35 shakaranshakaran 11.1k3 gold badges32 silver badges47 bronze badges 3
  • Maybe injecting a CSS rule to override this via extension would help. For example body{overflow: auto! important;} – K K Commented Jul 13, 2018 at 17:39
  • I think you're talking as a user of adblock. This is then not a programmer's question. Please contact adblock. – KIKO Software Commented Jul 13, 2018 at 17:41
  • You can't specify !important in a direct property assignment. You can do document.body.style.cssText = 'overflow: visible !important'; – woxxom Commented Jul 13, 2018 at 19:01
Add a comment  | 

2 Answers 2

Reset to default 18

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

*##html,body:style(overflow: visible !important;)

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";
})();

本文标签: javascriptHow to remove the css rule quotbody overflowhiddenquot automaticallyStack Overflow