daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Apr 17th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top