diff --git a/chrome/content/zotero/import/mendeley/authViewer.js b/chrome/content/zotero/import/mendeley/authViewer.js index d8e38b1469..c84e6caf3e 100644 --- a/chrome/content/zotero/import/mendeley/authViewer.js +++ b/chrome/content/zotero/import/mendeley/authViewer.js @@ -1,21 +1,24 @@ +/* eslint camelcase: ["error", {allow: ["Zotero_File_Interface"]} ] */ +/* global Zotero_File_Interface: false */ + Services.scriptloader.loadSubScript("chrome://zotero/content/fileInterface.js", window); const { E10SUtils } = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm"); const URI = `https://api.mendeley.com/oauth/authorize?client_id=5907&redirect_uri=https%3A%2F%2Fzotero-static.s3.amazonaws.com%2Fmendeley_oauth_redirect.html&response_type=code&state=&scope=all`; var startTime; -const tryExtractAuthCode = browser => { +const tryExtractAuthCode = (browser) => { const matchResult = browser.webNavigation.currentURI.spec .match(/mendeley_oauth_redirect.html(?:.*?)(?:\?|&)code=(.*?)(?:&|$)/i); return matchResult ? matchResult[1] : false; -} +}; -const clearCookies = since => { +const clearCookies = (since) => { const cookieManager = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager); const sinceμs = since * 1000; const cookiesSince = cookieManager.getCookiesSince(sinceμs); Zotero.debug(`Deleting ${cookiesSince.length} cookies created during Mendeley Auth (last ${(Date.now() - since)}ms)`); cookieManager.removeAllSince(sinceμs); -} +}; window.addEventListener('unload', () => { @@ -32,11 +35,11 @@ window.addEventListener("load", () => { startTime = Date.now(); - browser.addEventListener("pagetitlechanged", event => { + browser.addEventListener("pagetitlechanged", (_event) => { const mendeleyCode = tryExtractAuthCode(browser); if (mendeleyCode) { window.close(); - Zotero_File_Interface.showImportWizard({ mendeleyCode }) + Zotero_File_Interface.showImportWizard({ mendeleyCode }); } document.title = browser.contentTitle; }); diff --git a/chrome/content/zotero/standalone/basicViewer.js b/chrome/content/zotero/standalone/basicViewer.js index c46c6c918a..c150f27bb3 100644 --- a/chrome/content/zotero/standalone/basicViewer.js +++ b/chrome/content/zotero/standalone/basicViewer.js @@ -29,7 +29,8 @@ var browser; -window.addEventListener("load", /*async */function() { +window.addEventListener("load", /*async */function () { + browser = document.querySelector('browser'); ensureBrowserType('content'); /*