Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ads? On desktop? not in a million years with uBlock Origins. I forget how shitty internet is actually since several years now. Occasionally a new client doesn't have and I'm reminded of it, but it takes all of those 30 seconds to install it and no ads baby.


Actually I just started getting ads again, with uBlock Origin, both in YouTube and in newly-redesigned Facebook. I wrote a simple script that removes FB ads, but I need to "productivize" it and make sure it auto-loads...


Facebook's "sponsored" content is a disgusting mess of <span> elements with autogenerated IDs in order to bypass ad-blockers. How did you get around it?


It's a cat and mouse game. Every couple of months FB tries a new version of the HTML layout with slightly changed elements and every time someone writes a CSS selector that manages to find the appropriate tag for the sponsored story and hide it. Currently with the new FB redesign it's:

div[data-pagelet^="FeedUnit"]:has([role^=button]:has(> span:has-text(S)):not(:has-text(1)):not(:has-text(2)):not(:has-text(3)):not(:has-text(4)):not(:has-text(5)):not(:has-text(6)):not(:has-text(7)):not(:has-text(8)):not(span:has-text(9)):not(span:has-text(w)))


I find this so crazy! It says "Promoted" right there. I can use my browser's inspector to click on the element to select the div and then delete it.

Is there no simple way to accomplish the same in a browser extension without bringing in some crazy AI solution? Just read the webpage as it is rendered to an actual human, identify the x/y coordinates of the element, pass that to Firefox/Chrome/Safari's element selector, and delete. Voila!

I'm sure there's a very good reason why this exact solution just doesn't work, but I'd love to hear it explained, because it seems so simple to me. Then again I'm a backend guy, and I just don't even know frontend.


> Just read the webpage as it is rendered to an actual human

Humans read web pages using their vision. So what you’re proposing is to look at the final rendered image of text instead of the DOM tree. The only way to do that would be to perform OCR (https://en.wikipedia.org/wiki/Optical_character_recognition) on a screenshot of the whole web page. This would be possible, but I think nobody’s tried because it feels overly complicated, and many OCR libraries can’t understand text 100% reliably, not even computer-rendered text. Also remember that the OCR library would have to run in JavaScript. Would it run fast enough to block the ad before the user sees it? Would it annoy the user by spinning up their computer’s fan?

> identify the x/y coordinates of the element

This wouldn’t be too too hard to implement using `document.elementsFromPoint(x, y)`. This part isn’t the problem.


You could replace OCR with a CNN trained to predict bounding boxes of ads. You could generate the training data by looking at the visual diff between a page rendered with an ad blocker enabled, and the same page rendered with the ad blocker disabled.


I don't want a badly trained CNN accidentally removing relevant content from the page, though. The CSS selector solutions are deterministic, and you can't just throw ML at every damn thing you see.

Also, the problem with OCR/CNN solutions are that you have to render ahead (i.e. parts of the page that you haven't scrolled to yet) to remove ads without being disruptive to the website's content flow.


I'm not sure that facebook does it for the "promoted" text, but they have been known to mess with layout to make text difficult to detect. For example each character of a word might be in a separate <div> and be strangely offset so as to line up. The divs might not have the mutually common parent element that you would expect.


The browser has no context for what it is rendering. Should it ban every element containing "promoted"? Even posts by people?

The word "promoted" might not even appear as text, it might be simply a series of divs with one letter each (out of order, of course) and then visually defined with CSS.

The browser doesn't know it's rendering a word, it only knows it's rendering a series of divs with one letter on each, and it absolutely can't know what the visual representation of the divs spell.

What you are proposing is another crazy AI solution, OCR.

Which would mean to render the document, using pattern recognition delimit the area with the sponsored post, then pass those coordinates to the browser in order to select the currently visible element, then delete it.

Even then I could think of a thousand ways to beat this, because OCR can't see invisible things and you can do all sorts of fun stuff with invisible styling, and it'd be the same game of cat and mouse the ad blockers are currently running but at a higher level of abstraction.


I think the issue isn't finding the text "Promoted", but coming up with a way to figure out exactly which element containing that text to remove (because simply removing the text itself would not be a good solution). I imagine that Facebook could be doing something like generating a CSS class names on based by using a different seed or producing different element configurations that visually appear the same for each page load (or worse, for each ad on the page...)


I think, the uBlock Origin context menu does that?


Similar tactic on Twitter as well. I'm not even doing it for ad blocking necessarily, just to hide features I don't want like "who to follow" or all those nonstop COVID updates.

In case anyone interested: https://github.com/dawnerd/ublock-filters/blob/master/sites/...


How can they get away with these deceptive obfuscatory practices without breaking web accessibility standards (e.g. screen readers parsing alt text and meta data for the visually impaired/blind) without opening themselves up to serious liability and class action lawsuits?



I didn't know about FacebookTrackingRemoval. I always used facebook_adblock[1] instead, which seems to do almost the same and has worked very well for me most of the time. I'm also seeing other comments here trying to figure out other solutions. It's making me wonder how much duplicated effort is being spent on the same problem.

[1] https://addons.mozilla.org/en-US/firefox/addon/fb_ad_block/


Do what I did, delete your Facebook...


I keep planning to write this script, but never get around to it. One of those messy autogenerated ID spans is "aria-labeledby" a span that clearly contains the text "sponsored". And it would be hard (legally) for Facebook to stop doing that.


Speaking of sponsored content. Both eBay and Amazon are unusable without uBO to remove sponsored listings that completely mess up my sorting and filtering.


In javascript, `span.innerText == "sponsored"` ... I was surprised it was so easy, but it probably won't work for long though.


I have a plugin for chrome called FB Purity that removes all the embedded ads, and also strictly list the feed in chronological order.


Can't you just remove all posts that aren't from people in your friend list?


This would also remove posts by FOF who tag your friends (e.g., your friend is tagged in a post by his wife, whom you're not friends with).


When that happens, I usually just do a manual update on my filters. More often than not, someone has already updated it.


Try updating your filters.


Perhaps the issue is that UBlock Origin allows some ads. AdBlocker Ultimate, recommended by Firefox, faces that issue, removing all adds. See https://addons.mozilla.org/en-US/firefox/addon/adblocker-ult...

EDIT: I don't think UBlock Origin has acceptable ads anymore :)


> EDIT: I don't think UBlock Origin has acceptable ads anymore :)

uBlock Origin has _never_ had "acceptable" (or any other kind) of ads.


Note that uBlock Origin is also "recommended by Firefox". In fact for some time now it's been the only supported extension on Firefox preview on Android.


Prove it.


I'll do my best, swinglock. I heard somewhere that UBlock Origin has acceptable ads, and based on that, the AdBlocker Ultimate had an appeal to me of removing them all.

I went on to investigate on it, and couldn't find much on UBlock Origin having acceptable ads. Some shady UBlock Origin-like websites claimed that, but UBlock Origin itself blocked them.

I'm wrong about UBlock Origin having acceptable ads, from what I gathered. Thank you for questioning my claims, swinglock.


You are confusing Ad Block Plus (ABP) and uBlock Origin. ABP has acceptable ads, while uBlock Origin does not.


Authoritative reference for anyone else curious about this: https://github.com/gorhill/uBlock/blob/master/MANIFESTO.md


Kelamir, perhaps you are confusing UBlock Origin's policy with that of Adblock Plus.

https://adblockplus.org/en/acceptable-ads


I think you had a fuzzy memory of adblock allowing "acceptable" ads and mis-associated it. Human brains are like that.


I've never routinely run an adblocker in, whatever, 25 years online.

I've experimented with them here and there, and tend to find that the unintended consequences are as much of a hassle as the ads.

I keep meaning to try a PiHole but I'm not sure I'll have much better luck.


> unintended consequences

That is a rare thing for me these days with uBlock Origin. I assume you're referring to broken websites when using ad blocking.


I never really used an adblocker as well, but now I'm using nextdns which does really good filtering at the dns level (not affiliated).


What unintended consequences?


Sometimes checkout on storefront sites will rely on scripts served from domains that adblockers block. When this happens, it's easy enough to turn the adblocker off for a few minutes (or, conversely, to decide "nope I'm not shopping here").


Weird formatting, things not working and you not remembering/understanding why, trying to keep settings in sync across browsers and platforms, and so on.

IOW I've found it easier to tolerate ads and slow sites "functioning as intended" than the much-less-frequent but far-more-maddening broken functionality that takes me "longer than it should" to troublehsoot.

I'm not sure I've used uBlock though, mostly ABP over the years.


Adblockers broke EasyJets navigation on their website, I think they have since fixed it.


Do content creators get ad revenue if you block ads via that extension?


I hope this was a sarcastic comment and not a genuine question from an adblock user.

I mean, I hope all adblock users are aware that if everyone did as they do, the content they enjoy would not exist.


Or it would still exist, but would be monitized differently.


Sure, let's tell private entities how to monetize their content that we enjoy.


See, if instead of this sarcastic quip you had bothered to come up with an insightful comment I might have had a chance to understand what you're trying to say.

Is it really all that unreasonable, as a consumer, to favor certain monetization schemes over others?


It was a genuine question from someone who doesn’t use an ad-blocker.

I block trackers, which blocks most ads on the web, but Youtube’s ads are not affected by this, and I’m perfectly fine with that.


I enjoy a lot of content that has no ads at all


Then no adblocker needed!


Unless you have youtube premium, no


uBlock Origin also works very well on mobile, but you have to use Firefox. Mobile Chrome doesn't allow any extensions and I think we know why.


Because the APIs where too permissive and plugins would be a threat to privacy of the user because they could intercept everything.


So instead of fixing the API to enable enduser privacy from third party plugins, the API was simply removed to remove enduser privacy from trackers.


Yeah I know, I should have added a /s to my comment.


this technique also works for paywalls, which I don't think ublock can get around


And I like it that way actually. If I can't see your site with my adblocker I am not going to ever land it again there. I also have NoScript and what I do is something like this:

Step 1 - open your site. Can't see it? I try to allow JS in NoScript

Step 2 - Still can't see your site due to shitty various techniques? Then I re-enable NoScript and add it to blacklist to never land on it ever.

Step 3 - You're not unique, your info is duplicated by several other dozens as well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: