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

Script count is not working properly #1

Closed luciopaiva closed 7 years ago

luciopaiva commented 7 years ago

If the page has more than one frame, frames will conflict and the count for the last frame processed is the one that is going to prevail for that tab.

Clever way to fix it: instead of having the foreground script ask for scripts, the background script will listen for tab switching activities. When one happens, it will check if the tab has already loaded Witchcraft scripts. If it has, do nothing; if it hasn't load them now for each and every frame in the tab. That way we can easily count how many scripts were loaded through all frames at once (question: how do we find all the existing frames? And how do we inject scripts in the frames without them asking?).

The other easier way would be to make a note of the frame id as requests arrive (https://developer.chrome.com/extensions/runtime#type-MessageSender) and add them to a set by tab id.