Closed foxik closed 7 years ago
You are right, that is a bug I created. Looking at the code the problem is not in the messaging itself, but probably in the way the spellcheck.js
file is injected into the tabs. The proper way would be to inject it only the first time and then send the messages as needed. I will look at that this weekend, maybe the listener just need not to be an arrow function, but the old-fashioned named function.
I wouldn't be afraid of using as content_script
, there are only functions definitions, but injecting jQuery each and every time may be a hit.
Should I bump the version with the fix too?
Today I found out that the new messaging API usage is wrong -- notably, the
chrome.runtime.onMessage.addListener
inspellcheck.js
gets called every timekorektorSpellcheck
in korektor.js is called -- therefore, if spellchecking is performed for a second time in a tab, two spell-checking dialogs appear, and so on on third, forth, ..., attempt. (This happens both in Chrome and Firefox.)One way how to solve it is injecting
spellcheck.js
into every tab using themanifest.json.content_scripts
, but I am not willing to do that. Another way is to somehow register the listener only once for each tab, but I do not know how. So my solution would be to get rid of messaging and use string code injection once again.@MikkCZ Ideas?