news.ycombinator.com
Untitled
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.
评论
5 条预览评论 · 正在加载完整讨论请先登录 h4cker 账号,然后连接 Hacker News 后发表评论。
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.
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?
Maybe reverse tactics and block/hide anything that isn't something you want to see.