简体   繁体   中英

Problem with hiding DIV from website using GreaseMonkey

There's one site, where without ads you cannot view the content. I tried Anti-Ad Blocker already, but scripts made all links unusable.

I tried writing Greasemonkey script to hide those few ads by hand, but so far it doesn't work (and I have no idea why).

// ==UserScript==
// @name     Hide annoying shinden ads
// @include  https://shinden.pl/*
// @grant    GM_addStyle
// ==/UserScript==



var div = document.getElementById("banner-outer");
if (div) {
    div.style.display = "none";
}

And element I want to delete:

<div id="banner-inner" style="transform: matrix(0.99999, 0.00087, -0.00087, 0.99999, 0, 0);">
            ...
        </div>

Also sometimes different div appears out of random, that blocks whole site:

<div style="position: fixed; display: block; width: 100%; height: 100%; inset: 0px; background-color: rgba(0, 0, 0, 0); z-index: 300000;"></div>

I don't know how to remove it, as thus it doesn't have an ID.

PS Site is as follows: https://shinden.pl/

You can remove Div from webpage using code below.

If the random Div is creating inside the "banner-inner Div" then above solution helps creating such Divs.

If it is creating outside then have to find the Div by available properties like width, hieght , z-index along with grand parent of the Div(which has ID) to pinpoint and delete the created div.

// ==UserScript==
// @name     RemoveDiv
// @version  1.0
// @grant    none
// ==/UserScript==

var toBeRemoved = document.getElementById('banner-inner');
if (toBeRemoved) {
    toBeRemoved.parentNode.removeChild(toBeRemoved);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM