Hi,
I am working on a project where I need to identify the ads in a webpage and study them. I want to use ABP for effectively identifying the ads. But I noticed that ABP simply creates the CSS and passes it on to the browser.
From the source code:
In elemHide.js, apply() function:
Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheetService.USER_SHEET);
So I am not able to get a handle on the web element containing the advertisement.
Is there a way I can get a handle/reference to the web element for the ad itself? Any help will be appreciated.
Thanks.
Getting the web element for the blocked ad
Re: Getting the web element for the blocked ad
I thought that ABP for Firefox was able to show which elements were hidden, in the "Show Blockable Items" view; however, for content that is blocked (via nsIContentPolicy, not hidden via nsIStyleSheetService), it's harder to see what HTML elements contained the blocked content.
By the way, it is possible for content to be blocked while its containing element is also hidden, but one does not imply the other.
By the way, it is possible for content to be blocked while its containing element is also hidden, but one does not imply the other.
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
Re: Getting the web element for the blocked ad
Thanks lewisje for the response.
So I was wondering if both content policy and element hiding are two separate things towards blocking the ad content. Also I think you suggested that I should backtrack from the browser side to find out what web elements are getting blocked because the browser shows the blockable elements?
Kindly clarify.
Thanks!
So I was wondering if both content policy and element hiding are two separate things towards blocking the ad content. Also I think you suggested that I should backtrack from the browser side to find out what web elements are getting blocked because the browser shows the blockable elements?
Kindly clarify.
Thanks!
Re: Getting the web element for the blocked ad
Yes: nsIContentPolicy is used when ABP parses blocking filters, to keep URLs matching them (and not matching whitelist filters) from being loaded; nsIStyleSheetService is used when ABP parses hiding filters, building up a stylesheet in which the selector after each matching domain specifier (that is, after the first occurrence of ##) is added to a big list of selectors, for which the CSS rule {display:none!important} is specified, before injecting the big stylesheet into the document.ankar wrote:I was wondering if both content policy and element hiding are two separate things towards blocking the ad content
Blocking URL requests and hiding HTML elements are separate processes.
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
Re: Getting the web element for the blocked ad
Thanks for the explanation. I am trying to understand if there is any mechanism apart from content policy checking and hiding elements that Ad Block Plus follows to block ads? Or does it follow only these two approaches?
Additionally, with Ad block plus for Chrome, does the approach remain the same or does it change?
Additionally, with Ad block plus for Chrome, does the approach remain the same or does it change?
Re: Getting the web element for the blocked ad
The major difference between the Chrome and Firefox versions is that it's called the "webRequest API" in Chrome and it's less granular than nsIContentPolicy.
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.