Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'; /* globals AddonManager, */
- /**
- * Triggers the update of an extension in Firefox (version 60).
- * Paste the function in the Browser console (Ctrl+Shift+J) and call it.
- * This is pieced together from noLegacyStartupCheck > checkOne in
- * resource://gre/modules/addons/XPIProvider.jsm of Firefox 60.
- * It might not be wise to use this with a production profile.
- * @param {string} id The "Extension ID" from `about:debugging#addons`.
- */
- async function updateNow(id) {
- const addon = (await AddonManager.getAddonByID(id));
- const update = (await new Promise(resolve => addon.findUpdates({
- onUpdateFinished() { resolve(null); },
- onUpdateAvailable(addon, update) { resolve(update); },
- }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED))); // use UPDATE_WHEN_USER_REQUESTED instead?
- if (!update) { console.log('no update available'); return; }
- console.log('installing ...');
- try { (await new Promise((good, bad) => { update.addListener({
- onDownloadFailed: bad, onInstallFailed: bad, onInstallEnded: good,
- }); update.install(); })); }
- catch (error) { console.error('installation failed', error); return; }
- console.log('installation done');
- }
- void updateNow;
Add Comment
Please, Sign In to add comment