diff --git a/src/background/background.js b/src/background/background.js index 211bfef8..1fe230ed 100755 --- a/src/background/background.js +++ b/src/background/background.js @@ -338,6 +338,10 @@ chrome.runtime.onMessage.addListener((payload, sender, sendResponse) => { } else if (payload.type === "google-scholar") { fetchGSData(payload.paper).then(sendResponse); } else if (payload.type === "download-pdf-to-store") { + if (global.state.isSafari) { + sendResponse(false); + return; + } getStoredFiles().then((storedFiles) => { if (storedFiles.length === 0) { chrome.downloads.download({ diff --git a/src/popup/js/handlers.js b/src/popup/js/handlers.js index bee2cb19..bfd85e00 100644 --- a/src/popup/js/handlers.js +++ b/src/popup/js/handlers.js @@ -113,7 +113,7 @@ const handleMemoryOpenLocal = (e) => { global.state.papers[id] = updatePaperVisits(paper); setStorage("papers", global.state.papers); if (file && (file.id || file.id === 0)) { - chrome.downloads.open(file.id); + chrome.downloads?.open(file.id); } window?.close && window.close(); }; diff --git a/src/popup/js/memory.js b/src/popup/js/memory.js index 9ded4303..8db4d9eb 100644 --- a/src/popup/js/memory.js +++ b/src/popup/js/memory.js @@ -297,7 +297,7 @@ const focusExistingOrCreateNewPaperTab = (paper, fromMemoryItem) => { const hasFile = global.state.files.hasOwnProperty(paper.id); if (hasFile && !fromMemoryItem) { // this paper has a local file - chrome.downloads.open(global.state.files[paper.id].id); + chrome.downloads?.open(global.state.files[paper.id].id); } else { // no tab open or local file: open a new tab to the paper's pdf chrome.tabs.create({ diff --git a/src/popup/js/popup.js b/src/popup/js/popup.js index 7b0616b4..ed4ab128 100644 --- a/src/popup/js/popup.js +++ b/src/popup/js/popup.js @@ -448,7 +448,7 @@ const popupMain = async (url, is, manualTrigger = false, tab = null) => { addListener(`popup-memory-item-openLocal--${id}`, "click", async () => { const file = (await findLocalFile(paper)) || global.state.files[paper.id]; if (file) { - chrome.downloads.open(file.id); + chrome.downloads?.open(file.id); } else { chrome.tabs.create({ url: paper.pdfLink }); } @@ -519,6 +519,8 @@ const popupMain = async (url, is, manualTrigger = false, tab = null) => { // ------------------------------ const query = { active: true, lastFocusedWindow: true }; +console.log("navigator.userAgent: ", navigator.userAgent); +console.log("state: ", global.state); if (window.location.href.includes("popup")) { chrome.tabs.query(query, async (tabs) => { chrome.runtime.connect({ name: "PaperMemoryPopupSync" }); diff --git a/src/popup/min/popup.min.html b/src/popup/min/popup.min.html index 7e4fbf4c..95fdaea9 100755 --- a/src/popup/min/popup.min.html +++ b/src/popup/min/popup.min.html @@ -1,5 +1,5 @@