lykahb / sticky-ducky

A browser extension that cleans pages of the sticky elements and shows them when needed. Fast and simple.
Other
19 stars 4 forks source link

Domain ignore entries also cause stickies on other domains with same string length to be ignored #12

Closed steven676 closed 3 years ago

steven676 commented 3 years ago

If you add ||twitter.com to the ignore list, you'll find that sticky headers on nytimes.com aren't disappeared by Sticky Ducky, as expected. Further testing suggests that adding any domain ignore entry with the same length as the current domain (or one of the current domain's parent domains) causes this to happen: ||7777777.zzz breaks Sticky Ducky on nytimes.com, ||88888888.zzz or ||666666.zzz does not. This occurs on Firefox 84/Linux and Chrome 87/ChromeOS, at least.

I suspect this is due to the code at https://github.com/lykahb/sticky-ducky/blob/master/src/js/whitelist.js#L50:

let index = location.hostname.endsWith(rule.domain);
if (index < 0) return false;

MDN says that String.prototype.endsWith() returns a boolean, not an index into the string, so index < 0 is never true and execution always continues into the following length comparison code.

lykahb commented 3 years ago

That's a good find! Would you like to open a PR?