4 ms·
> 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 rendere
by roryokane 6y ago
> 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 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.
- abrichr 6y agoYou 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.
- grenoire 6y agoI 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.