Reputation: 3941
I've got a chrome extension that I update frequently, and so I wrote an update notification popup for it. It displays when the manifest.version changes so that the user doesn't miss that there was an update with new options that they'd need to enable/disable. Then I realized that for minor big fixes and the like, it doesn't make sense to bug the user. Because I have to update the manifest version everytime I update the script, I thought it would be nice to just have an 'new_options' : true
field in the manifest that my script could key off of. Unfortunately when I tried it I get this:
Is there some way to add your own custom key/value entries in the chrome manifest?
I checked the documentation and it doesn't appear that there are any "free JSON" enabled keys, but I thought I'd ask before completely giving up on the idea. I could easily put a global flag in the script itself, but I know me, and I'm liable to forget to change it every update.
Upvotes: 2
Views: 2211
Reputation: 349042
Although the "Unrecognised manifest key 'new_options'" warning can safely be ignored, I recommend to not abuse this method for toggling features. An extension cannot change its manifest file, so having a hypothetical "new_options": true
field would not be very useful.
A better way to manage notifications for updates is to consistently stick to the following convention and use chrome.runtime.onInstalled
:
For example:
chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == 'install') {
// First-run code here.
// TODO: Thank the user for installing the extension
} else if (details.reason == 'update') {
// Check for update
var versionPartsOld = details.previousVersion.split('.');
var versionPartsNew = chrome.runtime.getManifest().version.split('.');
if (versionPartsOld[0] != versionPartsNew[0]) {
// Major version change!
// TODO: Show changelog for update?
}
}
});
Upvotes: 5