Is there a way to trigger custom JavaScript on ad detection?

Everything about using Adblock Plus on Google Chrome

Is there a way to trigger custom JavaScript on ad detection?

Postby AcidShout » Tue Jul 22, 2014 10:03 pm

Hi there!

I found a web page which adds an event listener to the ad <div>, and if it's removed / hidden / etc, it simply creates another one. If it's hidden with display: none;, then the entire page disappears.

So I thought I could remove it with a bit of JavaScript, and came up with this:
Code: Select all
var x;
while(x = document.getElementById('ad17')){
    x.removeEventListener('DOMNodeRemoved');
    x.parentNode.removeChild(x);
}


That effectively solves the problem if I run it, but I don't want to run that each time I browse to a new page.
Is there any way to make AdBlock for Chrome to execute my custom JavaScript when it detects #ad17?

Thanks!
AcidShout
 
Posts: 2
Joined: Tue Jul 22, 2014 10:00 pm

Re: Is there a way to trigger custom JavaScript on ad detection?

Postby mapx » Tue Jul 22, 2014 10:15 pm

no, you can't do what you want using ABP
but which is that page/site ?
User avatar
mapx
 
Posts: 21947
Joined: Thu Jan 06, 2011 3:01 pm

Re: Is there a way to trigger custom JavaScript on ad detection?

Postby AcidShout » Tue Jul 22, 2014 10:21 pm

It's private, and requires a paid registration.

Anyway I can give some research about the styling if you want
AcidShout
 
Posts: 2
Joined: Tue Jul 22, 2014 10:00 pm

Re: Is there a way to trigger custom JavaScript on ad detection?

Postby lewisje » Mon Feb 29, 2016 12:22 pm

I didn't notice this thread when it was first posted, but I'll just say that .removeEventListener requires both the event name and the same function that had been added as the event listener (and also the same value of the third argument, the "useCapture" parameter, that had been used to add the event); unfortunately, there's no way in vanilla DOM/JS to say "remove all listeners on this element for this event" without having references to all event listeners already (and no way to enumerate all event listeners): https://developer.mozilla.org/en-US/doc ... ntListener
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
lewisje
 
Posts: 2744
Joined: Mon Jun 14, 2010 12:07 pm


Return to Adblock Plus for Chrome support

Who is online

Users browsing this forum: No registered users and 213 guests