Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [-ext-has="selector"] attribute support to element hiding rules #321

Closed
ameshkov opened this issue Aug 10, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@ameshkov
Copy link
Member

commented Aug 10, 2016

It should work just like :has() pseudo class from CSS4 specification. Raymond has already done it in uBO.

The problem with it is that ":has" pseudo class is not a valid pseudo class, hence using it may break old versions of AG.

To solve this and make filters compatible with the old versions I suggest using another approach. It should look like a simple attributes selector.

For instance, here is how to block yandex search ads using this new modifier:
yandex.ru##.serp-item[-ext-has=".label.label_color_yellow"]

@ameshkov ameshkov modified the milestones: 2.4, 2.5 Aug 10, 2016

@ameshkov

This comment has been minimized.

Copy link
Member Author

commented Aug 10, 2016

@Mizzick I think that to make it work we need to introduce a separate library.

Something like that:

var extendedCss = (function() {....})();
var selector = extendedCss.live('.serp-item[-ext-has=".label.label_color_yellow"]');
selector.change(function(e) {
    e.target.parentNode.remove(e.target);
});
@ameshkov

This comment has been minimized.

Copy link
Member Author

commented Aug 10, 2016

Or maybe something even simpler?

var extendedCss = (function() {....})();
var cssText = '.serp-item[-ext-has=".label.label_color_yellow"] { display: none!important; }';
extendedCss.apply(cssText);
@ameshkov

This comment has been minimized.

Copy link
Member Author

commented Aug 10, 2016

I suggest starting from implementing something like that:

var ExtendedSelector = (function() {

    var extractCommonSelector = function(selectorText) {
        // TBD
    };

    var extractExtendedPseudoClasses = function(selectorText) {
        // TBD
    };

    var checkExtendedClasses = function(element, extendedClasses) {
        // TBD
    };

    return function(selectorText) {

        this.selectorText = selectorText;
        this.commonSelector = extractCommonSelector(selectorText);
        this.extendedClasses = extractExtendedPseudoClasses(selectorText);

        this.queryAll = function() {
            var result = [];
            var elements = document.querySelectorAll(this.commonSelector);
            var iElements = elements.length;
            while (--iElements) {
                var element = elements[iElements];
                if (checkExtendedClasses(element, this.extendedClasses)) {
                    result.push(element);
                }
            }
            return result;
        };
    }
})();

Mizzick added a commit that referenced this issue Aug 10, 2016

Mizzick added a commit that referenced this issue Aug 11, 2016

Mizzick added a commit that referenced this issue Aug 11, 2016

Mizzick added a commit that referenced this issue Aug 11, 2016

Mizzick added a commit that referenced this issue Aug 11, 2016

Mizzick added a commit that referenced this issue Aug 12, 2016

Mizzick added a commit that referenced this issue Aug 12, 2016

Mizzick added a commit that referenced this issue Aug 12, 2016

Mizzick added a commit that referenced this issue Aug 12, 2016

Mizzick added a commit that referenced this issue Aug 15, 2016

Mizzick added a commit that referenced this issue Aug 15, 2016

ameshkov added a commit that referenced this issue Aug 16, 2016

Mizzick added a commit that referenced this issue Aug 16, 2016

Mizzick added a commit that referenced this issue Aug 16, 2016

Mizzick added a commit that referenced this issue Aug 16, 2016

Mizzick added a commit that referenced this issue Aug 17, 2016

Mizzick added a commit that referenced this issue Aug 17, 2016

Mizzick added a commit that referenced this issue Aug 18, 2016

Mizzick added a commit that referenced this issue Aug 18, 2016

Mizzick added a commit that referenced this issue Aug 18, 2016

Mizzick added a commit that referenced this issue Aug 18, 2016

Mizzick added a commit that referenced this issue Aug 18, 2016

Mizzick added a commit that referenced this issue Aug 19, 2016

Mizzick added a commit that referenced this issue Aug 19, 2016

@Mizzick Mizzick modified the milestones: 2.4, 2.5 Aug 19, 2016

@Mizzick Mizzick closed this Aug 19, 2016

Mizzick added a commit that referenced this issue Aug 19, 2016

Mizzick added a commit that referenced this issue Aug 19, 2016

maximtop pushed a commit that referenced this issue Feb 7, 2019

Maxim Topciu
Merge pull request #321 in EXTENSIONS/browser-extension from fix/1219…
… to master

* commit '408c7f1f7d064e34953a1a73105ccfebeacf3f92':
  fix/1219 add stealth actions if cookies were modified in stealth mode
  fix/1219 add stealth mode name to the request rules without id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.