3 ms·
Cool! Just curious, why do you query 10 times per second for a feed? This seems kind of excessive and maybe a bit bad for battery life, especially since this co
by jsf01 3y ago
Cool! Just curious, why do you query 10 times per second for a feed? This seems kind of excessive and maybe a bit bad for battery life, especially since this could be running in several tabs at once.
- zukerpie 3y agoThis is just the straightforward idea of waiting for some element to appear on the website. But once the element is found, this thing stops. It won't stop for YouTube if you are on Facebook though but it's just a first implementation and it could actually be very easy to recognize the site. Thanks for the helpful suggestion!
- rendall 3y agoI wrote an extension that did something similar for Twitter, back when Twitter had "So-and-so liked this" tweet, which was inevitably something awful. It's archived now, because it's no longer relevant. But you might find something useful in the code. I tried polling, but it was against the Chrome extension guidelines at the time, so I used a "mutationObserver" on page load and then a "scrollListener". I don't remember if I ever tried an "intersectionObserver" but that might be worth looking at. https://github.com/rendall/twitter-like-hider/blob/master/content_script.js https://github.com/rendall/twitter-like-hider/blob/master/co...
- joshxyz 3y agohey just curious, can't the mutationobserver catch this instead of that approach? https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver https://developer.mozilla.org/en-US/docs/Web/API/MutationObs...
- zukerpie 3y agoDefinitely! The current implementation is supposed to just do the work. It's not meant to be optimized or anything.
- zukerpie 3y agoAdded a quick domain check to avoid the issue that you've mentioned :)
- chalsprhebaodu 3y agoI believe you could use a sub tree mutation observer instead of polling.
- Groxx 3y agoYes, definitely use mutation observers. Far faster to react and doesn't require polling, they're better in essentially every way when things aren't changing many times per second.