Guest User

Untitled

a guest
Apr 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. 'use strict'; /* globals AddonManager, */
  2.  
  3. /**
  4. * Triggers the update of an extension in Firefox (version 60).
  5. * Paste the function in the Browser console (Ctrl+Shift+J) and call it.
  6. * This is pieced together from noLegacyStartupCheck > checkOne in
  7. * resource://gre/modules/addons/XPIProvider.jsm of Firefox 60.
  8. * It might not be wise to use this with a production profile.
  9. * @param {string} id The "Extension ID" from `about:debugging#addons`.
  10. */
  11. async function updateNow(id) {
  12. const addon = (await AddonManager.getAddonByID(id));
  13. const update = (await new Promise(resolve => addon.findUpdates({
  14. onUpdateFinished() { resolve(null); },
  15. onUpdateAvailable(addon, update) { resolve(update); },
  16. }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED))); // use UPDATE_WHEN_USER_REQUESTED instead?
  17. if (!update) { console.log('no update available'); return; }
  18. console.log('installing ...');
  19. try { (await new Promise((good, bad) => { update.addListener({
  20. onDownloadFailed: bad, onInstallFailed: bad, onInstallEnded: good,
  21. }); update.install(); })); }
  22. catch (error) { console.error('installation failed', error); return; }
  23. console.log('installation done');
  24. }
  25.  
  26. void updateNow;
Add Comment
Please, Sign In to add comment