sitexw / BlockAdBlock

Allows you to detect the extension AdBlock (and other)
http://fuckadblock.sitexw.fr/blockadblock/
MIT License
614 stars 119 forks source link

Multiple instances #24

Closed denissteinhorst closed 7 years ago

denissteinhorst commented 7 years ago

Hey there.. first i want to say that your script is exactly what im looking for but, in my case it wont work as expected.

It blocks / replaces one entry fine but as soon as i add a secound id="..." to check again it fails..

testet the same behaviour on your site, seems like you cant have multiply requests at the same time..

(in my example i have 4 ads in a row that should be replaced with other images as soon as adb is detected, first one works fine, the other 3 get ignored)

what can i do?

sitexw commented 7 years ago

First, thank you for your enthusiasm for BlockAdBlock.

If I understand correctly, currently, you create an instance of BlockAdBlock for each ad block? And do you have a small example of a script?

denissteinhorst commented 7 years ago

WOW! Thanks for the fast reply! thats pretty awesome!

sure, there you got the part of my code:

https://pastebin.com/xx9YKuJN

on top of the page i just include your .js file btw: im using bootstrap - may this info will help you

sitexw commented 7 years ago

You have more, a problem of jQuery, than of BlockAdBlock =)

In the world of development, typically the IDs are made to be unique. In your case, you try to create elements with the same ID and jQuery does not tolerate it, that's why it only works with a single ID. In your case, it would be better to use "class" instead of "id". Here is a concrete example that shows the difference between "id" and "class" with jQuery: https://codepen.io/anon/pen/eWqWrp

denissteinhorst commented 7 years ago

Oh my God!... how i could not see that!... u are totaly right, in general im aware of classes and ids. - i just didnt mentioned the IDs instead of classes.

im so sorry to interrupt you with such a nasty misstake.

keep going with the good work and hold up that blazing fast support! 10/10.

regards

sitexw commented 7 years ago

No problem, and good continuation.