views:

562

answers:

2

I have a Greasemonkey script that is trying to access an HTML element that Adblock is disabling. Is it possible to create a workaround with the Greasemonkey script to prevent conflicts with the Adblock plugin?

I'm open to any ideas, however changing the script to avoid the Adblock element is not a solution at this time.

Additional Info

The addblock element I am trying to "enable" is a Table element from a google search result.

<table id="mbEnd" width="30%" style="margin-bottom: 1em;">

The Adblock filter hiding the element is:

google.com,google.com.au,google.co.uk,google.ca,google.se#table(id=mbEnd)(width=30%)

Update: Some are suggesting that I simply disable the adblock filter for the page I am working on. I also consider this a non-solution, since anyone using my script would have to perform the same action, and I can not expect all my users to manually modify their Adblock settings.

+1  A: 

You can disable adblock for specific pages or domains. Just click the arrow next to the symbol and it'll give you more options for disabling adblock.

There is no way to make a Greasemonkey script automatically override Adblock, as Adblock affects the page before any Greasemonkey scripts are loaded.

Daniel Lew
I think the interesting point is the manner that Adblock affects the page. It does NOT parse the HTML element from the document, but my understanding is that it applies a user CSS style sheet to the document that hides the HTML element. See http://adblockplus.org/en/faq_internal#elemhide
Casey
ABP removes as much content as it can detect as being an ad link, and only goes to element hiding if it is unavoidable (http://adblockplus.org/en/filters#elemhide_basic). If the only issue was element hiding, you'd be able to access the DOM element, since CSS won't hide it from JavaScript.
Daniel Lew
Thus, I stick with my original answer, which is that Greasemonkey will lose to ABP. If the element is blocked by ABP, how is any JavaScript ever supposed to get at it?
Daniel Lew
I verified that the element in question is not parsed from the document if that helps.
Casey
A: 

What type of elements are you trying to access? Most of the page elements should still be available, just with 'display: none;'.

I use jQuery in my Greasemonkey scripts and it is able to get the alt text from an image after I have disabled it with ABP.

$('#s1 + img')[0].alt
=> Rohm and Haas Paint Quality Institute

If you provide some more specific information I may be able to provide a more specific solution.

Accessing iframes that are blocked may be harder but doable. Again, more specifics will help me answer.

Daniel X Moore