Skip to content

Instantly share code, notes, and snippets.

@DannyAziz
Created March 13, 2024 19:55
Show Gist options
  • Save DannyAziz/f017f23eb592f63caa893cff1ad280b9 to your computer and use it in GitHub Desktop.
Save DannyAziz/f017f23eb592f63caa893cff1ad280b9 to your computer and use it in GitHub Desktop.
Update content script
chrome.runtime.onInstalled.addListener(async function (details) {
if (details.reason === "update") {
for (const cs of chrome.runtime.getManifest().content_scripts) {
for (const tab of await chrome.tabs.query({ url: cs.matches })) {
for (const file of cs.js) {
chrome.scripting.executeScript({
target: { tabId: tab.id, allFrames: cs.all_frames ?? false },
files: [file]
})
}
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment