They do this by adding a ton of useless markup and splitting words like "ad" into single-letter spans with random class names and 8-layer deep nests of `<div>` so it's very hard to write selectors against. One has to wonder how that div soup affects accessibility as I find it very unlikely that this content is presented nicely to assistive tools. I hope they get all the ADA suits they deserve for this.
Last I tried writing custom rules for Facebook was years ago, but they did have proper aria attributes, and uBlock origin does have selectors for text content. These are from 2020:
facebook.com##span:has-text(Suggested for You):xpath(../../../../../../../../../../../../../../../../../..)
facebook.com##div[aria-label="Sponsored"] span[aria-label="Sponsored"]:xpath(../../../../../../../../../../../../../../../../../../../../..)
facebook.com##div[aria-label="Sponsored"]:xpath(../../../../../../../../../../../../../../../../../../../..)But can't they just use an xpath expression to test the computed text content of a node, like `/path/to/ad/div[contains(., 'sponsored')]`? In that expression, there could be any number of nested elements inside the terminal `<div>` and it wouldn't matter. (And you'd probably have to use a regex test to account for tricky white space.)
> so it's very hard to write selectors against
This sounds perfectly matched for an on-device LLM?
> I hope they get all the ADA suits they deserve for this.
So what you're saying is: you want Facebook to pay out something like $200M which is such a small amount it won't even realize, $170M will go to lawyers, everybody else gets $1.30.
That seems like how it might pan out.
Could you not just go after the deeply nested spans? I assume they aren't messing up everything else like that.
I recently found this out the hard way. Instagram’s web app has a super annoying popup. To click the comments button for a post, your cursor has to pass over the username, which just happens to launch a profile preview with the “follow” button exactly where the comments button was, causing you to unintentionally follow the account.
I tried to block this popup with uBlock Origin to no avail. No matter what element I selected, it was still there. Finally fixed the problem by deleting my Instagram account.