Closed fmorroni closed 2 years ago
Good suggestion! Yes, I think it would be better to search on body.innerText. Let me do some testing on it.
Implemented in version 1.5. Now only body.innerText is checked for keywords.
Implemented in version 1.5. Now only body.innerText is checked for keywords.
Amazing thanks!
Description
Keywords are detected outside of site content. For example if I add a keyword like ~translate3d, and go into github.com, the site will be blocked. This is because in the html styling of the site the translate3d function is used, and leechblock detects this. I think everyone will agree that this shouldn't be the intended effect.
I believe the issue is with the checkKeyword function at content.js. I declared the function in devtools (with some modifications to print more information) and used it to search for translate3d:
As you can see, the function detects the css styling in the head of the html, and probably other things that doesn't make sense for it to detect.
Steps to reproduce
Check the html of any site for words in the styling (I've only tried with styling in the head, I don't know if it works with inline styles) that can't be found anywhere in the content of the site. Add that word as a keyword in a block. The site will get blocked.
Possible solutions
I think the keyword search should only be done on the the body's innerText property. That way only the actual site's content will be used to block and not unrelated stuff from its html.