Skip to content

Instantly share code, notes, and snippets.

@bongkook
Last active January 26, 2023 11:23
Show Gist options
  • Save bongkook/388d71337f72c0fe1192912b61e45003 to your computer and use it in GitHub Desktop.
Save bongkook/388d71337f72c0fe1192912b61e45003 to your computer and use it in GitHub Desktop.
chrome.runtime.onUpdateAvailable.addListener(function(details) {
console.log("updating to version " + details.version);
chrome.runtime.reload();
});
chrome.runtime.requestUpdateCheck(function(status) {
if (status == "update_available") {
console.log("update pending...");
} else if (status == "no_update") {
console.log("no update found");
} else if (status == "throttled") {
console.log("Oops, I'm asking too frequently - I need to back off.");
}
});
// background.js
chrome.runtime.onUpdateAvailable.addListener((details) => {
if (details) {
// if you 100% sure about this.
// chrome.runtime.reload();
// too distract.
// alert(`New version (${details.version}) is available. Restart the browser to update.`);
// requires `notifications` permission.
// chrome.notifications.create({
// type: "basic",
// iconUrl: chrome.extension.getURL("logo-48.png"),
// title: "Update available",
// message: `New version (${details.version}) is available. Restart the browser to update.`
// });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment