Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting element with jQuery based on css attributes?

Wouldn't ask if I really couldn't find an answer. So here is my problem. A website I use, uses a loophole around uBlock, it uses a script to overlay a random generated element class such as:

<div class="lcelqilne1471483619510ttupv"></div>
<div class="xgdxts1471483770461tkbfjhcr"></div>

The string changes every time, so selecting it makes it impossible on a constant basis. This class overlays the website, forcing you to click it and receive a popup/ad, that some how uses Base64 exploit or something to bypass and display a working popup/newtab. However it does have CSS variables that in theory can select the class/ID. I however have no Idea how to do it with javascript/jQuery(with greasemonkey). The popup is also invisible.

display: block !important;
visibility: visible !important;
top: 0px !important;
left: 0px !important;
position: absolute !important;
z-index: 999999 !important;

To simplify what I am asking, I would like to select this element based on its CSS attributes and not the name of the element, then hide/block it. http://prntscr.com/c7474u

like image 311
computerguy Avatar asked Apr 07 '26 03:04

computerguy


1 Answers

You can use .filter() to check the computed style for the settings you want.

$("div[class]").filter(function() {
    if (this.className.length != 27) { // skip the expensive style check if we don't have a random-looking class
        return false;
    }
    var style = getComputedStyle(this);
    return (style.visibility == 'visible' && style.top == '0px' && style.left == '0px' && style.position == 'absolute' && style.zIndex == 999999);
}).hide();

I suspect this will be pretty expensive. If you can narrow down the selector it would help.

like image 152
Barmar Avatar answered Apr 08 '26 16:04

Barmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!