Guest Posted July 16, 2013 Report Share Posted July 16, 2013 (edited) hello, i just had an idea for a thing, namely an inverted adblock browser extension which filters out anything which is not on a adblock blacklist. i.e. you get to see ads only. please note that i do not ask your opinion on why this is a stupid idea. okay? unless it is a lol opinion then it's okay. now, i do know programmering, but haven't ever done anything related to website tinkering. so the question is, what would be the basic steps to implement a content filter in js? it shouldn't block entire sites, but needs to get rid of .html content which is not on the ad-provider whitelist.... Edited July 16, 2013 by Guest Quote Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/ Share on other sites More sharing options...
mcbpete Posted July 16, 2013 Report Share Posted July 16, 2013 It's only a theory but could you just use adblock and cut the filter list from the blacklist and paste into the whitelist ? Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide all signatures I haven't eaten a Wagon Wheel since 07/11/07... ilovecubus.co.uk - 25ml of mp3 taken twice daily. Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036917 Share on other sites More sharing options...
th555 Posted July 16, 2013 Report Share Posted July 16, 2013 It would be funny to make a site that replaces all images and coloured rectangles with ads, but keeps the layout intact. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide th555's signature Hide all signatures https://www.youtube.com/user/THkaas/videos https://thisjepisje.bandcamp.com/ https://soundcloud.com/th555 Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036919 Share on other sites More sharing options...
Guest Posted July 16, 2013 Report Share Posted July 16, 2013 yes, that would be an efficient solution! currently searching for where adblock stores its filter lists. but it would be great if I could distribute this thing, so modifying the adblock source to swap its filter lists would be the way to go probably. Quote Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036924 Share on other sites More sharing options...
Guest Posted July 16, 2013 Report Share Posted July 16, 2013 On 7/16/2013 at 12:34 PM, th555 said: It would be funny to make a site that replaces all images and coloured rectangles with ads, but keeps the layout intact. yea i'm wondering, that should actually be possible with an extension, e.g. wouldn't this be quite simple with images? like: foreach image request replace image url with random ad image url instead. as i said, i don't have web dev experience, but isn't all web development basically copy paste from somewhere? Quote Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036928 Share on other sites More sharing options...
Guest Posted July 16, 2013 Report Share Posted July 16, 2013 but what i want to do, with a bit of luck it's simply inverting a bool value at the right spot in the adblock code somewhere, hopefully? Quote Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036929 Share on other sites More sharing options...
Guest Posted July 16, 2013 Report Share Posted July 16, 2013 this is, I think, what adblock uses to match the document against the set of elements to be filtered: var results = document.querySelectorAll(selector); it goes on to destroy all elements which are contained in 'results'. do you know if there's a way to invert this, i.e. give me all elements which do NOT match the selector? Quote Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036948 Share on other sites More sharing options...
mcbpete Posted July 16, 2013 Report Share Posted July 16, 2013 I could be wrong buy I think the '==' is used to assess equality/matches (with the opposite being '!=') wheras the single equals just means it assigns the result on the right to the variable on the left. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide all signatures I haven't eaten a Wagon Wheel since 07/11/07... ilovecubus.co.uk - 25ml of mp3 taken twice daily. Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036951 Share on other sites More sharing options...
Ego Posted July 16, 2013 Report Share Edit Hide Delete Posted July 16, 2013 (edited) You probably don't want to destroy elements because that will just collapse the page. It wont be as simple as flipping a boolean because you might have an element containing an ad you want to show. If you hide or destroy the outer element you'll just hide everything contained inside. Adblock doesn't need to preserve content within a blocked element. I'd say your best bet would be to add a blank layer over the page, extract the elements and their position you want to show and display them on top of your blank layer. I would use the element matching code of adblock so you can use their filter lists to extract the DOM elements you want to keep. Edited July 16, 2013 by Ego Quote Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036979 Share on other sites More sharing options...
Guest Posted July 16, 2013 Report Share Posted July 16, 2013 yes yes.... so how about, for each matched element, traverse the DOM back to the root, and basically rebuild the DOM containing only the branches which contain ad elements at the end? Quote Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2036996 Share on other sites More sharing options...
th555 Posted July 16, 2013 Report Share Posted July 16, 2013 Yes it would be quite simple, like using a pattern of ads as the background for all divs or something. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide th555's signature Hide all signatures https://www.youtube.com/user/THkaas/videos https://thisjepisje.bandcamp.com/ https://soundcloud.com/th555 Link to comment https://forum.watmm.com/topic/79745-attn-web-devs/#findComment-2037116 Share on other sites More sharing options...
Recommended Posts