Fix double <browser> regression in basicViewer #3039
This commit is contained in:
parent
1af3142c52
commit
3eeac6f8b0
2 changed files with 11 additions and 7 deletions
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
var browser;
|
||||
|
||||
window.addEventListener("load", /*async */function() {
|
||||
window.addEventListener("load", /*async */function () {
|
||||
browser = document.querySelector('browser');
|
||||
ensureBrowserType('content');
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue