luciopaiva / witchcraft

Inject Javascript and CSS right from your file system. Think GreaseMonkey for more advanced users.
https://luciopaiva.com/witchcraft
MIT License
260 stars 19 forks source link

Fix script count #7

Closed luciopaiva closed 7 years ago

luciopaiva commented 7 years ago

My approach ended up being different from what was proposed on #1. I decided to, instead of storing the script count, storing script names in a set instead. That way the script can just add new script names to the set and, in case they were already loaded by another frame in the same tab, we still won't count them more than once. The second necessary change is to clear that set whenever a new request for frameId 0 (i.e., the top frame on that tab) is made. This way we can know when a page refresh is taking place, so we can invalidate the previous set of script names and the count will always be consistent.