Always try CS reinjection (safe since we ping first)

This commit is contained in:
tophf 2017-03-16 13:17:42 +03:00
parent 08509b8cc2
commit f86a6489ef

View File

@ -205,19 +205,9 @@ chrome.storage.local.get('version', prefs => {
} }
}); });
// after the extension was enabled or just installed injectContentScripts();
// reason = 'update' is needed becase our listener processes only 'update' events
injectContentScripts({reason: 'update'});
// after an actual update function injectContentScripts() {
chrome.runtime.onInstalled.addListener(injectContentScripts);
function injectContentScripts({reason, previousVersion, id} = {}) {
// reason: install, update, chrome_update, shared_module_update
// the "install" case is ignored because it was already handled by explicit invocation of this function
if (!/update/.test(reason)) {
return;
}
const contentScripts = chrome.app.getDetails().content_scripts; const contentScripts = chrome.app.getDetails().content_scripts;
for (let cs of contentScripts) { for (let cs of contentScripts) {
cs.matches = cs.matches.map(m => m == '<all_urls>' ? m : wildcardAsRegExp(m)); cs.matches = cs.matches.map(m => m == '<all_urls>' ? m : wildcardAsRegExp(m));