Skip to content

Commit 4e868ab

Browse files
committed
♻ refactor: WIP -> towards safari
1 parent 3e92295 commit 4e868ab

File tree

13 files changed

+97
-13
lines changed

13 files changed

+97
-13
lines changed

src/background/background.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ chrome.runtime.onMessage.addListener((payload, sender, sendResponse) => {
338338
} else if (payload.type === "google-scholar") {
339339
fetchGSData(payload.paper).then(sendResponse);
340340
} else if (payload.type === "download-pdf-to-store") {
341+
if (global.state.isSafari) {
342+
sendResponse(false);
343+
return;
344+
}
341345
getStoredFiles().then((storedFiles) => {
342346
if (storedFiles.length === 0) {
343347
chrome.downloads.download({

src/popup/js/handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const handleMemoryOpenLocal = (e) => {
113113
global.state.papers[id] = updatePaperVisits(paper);
114114
setStorage("papers", global.state.papers);
115115
if (file && (file.id || file.id === 0)) {
116-
chrome.downloads.open(file.id);
116+
chrome.downloads?.open(file.id);
117117
}
118118
window?.close && window.close();
119119
};

src/popup/js/memory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const focusExistingOrCreateNewPaperTab = (paper, fromMemoryItem) => {
297297
const hasFile = global.state.files.hasOwnProperty(paper.id);
298298
if (hasFile && !fromMemoryItem) {
299299
// this paper has a local file
300-
chrome.downloads.open(global.state.files[paper.id].id);
300+
chrome.downloads?.open(global.state.files[paper.id].id);
301301
} else {
302302
// no tab open or local file: open a new tab to the paper's pdf
303303
chrome.tabs.create({

src/popup/js/popup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ const popupMain = async (url, is, manualTrigger = false, tab = null) => {
448448
addListener(`popup-memory-item-openLocal--${id}`, "click", async () => {
449449
const file = (await findLocalFile(paper)) || global.state.files[paper.id];
450450
if (file) {
451-
chrome.downloads.open(file.id);
451+
chrome.downloads?.open(file.id);
452452
} else {
453453
chrome.tabs.create({ url: paper.pdfLink });
454454
}
@@ -519,6 +519,8 @@ const popupMain = async (url, is, manualTrigger = false, tab = null) => {
519519
// ------------------------------
520520

521521
const query = { active: true, lastFocusedWindow: true };
522+
console.log("navigator.userAgent: ", navigator.userAgent);
523+
console.log("state: ", global.state);
522524
if (window.location.href.includes("popup")) {
523525
chrome.tabs.query(query, async (tabs) => {
524526
chrome.runtime.connect({ name: "PaperMemoryPopupSync" });

src/popup/min/popup.min.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="../../shared/min/theme.min.js"></script><style>@import url("https://fonts.googleapis.com/css2?family=Yantramanav:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;1,600&display=swap");
2-
@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap");</style><link rel="stylesheet" type="text/css" href="../css/select2.min.css"><link rel="stylesheet" type="text/css" href="../../shared/css/bootstrap-utilities.min.css"><link rel="stylesheet" type="text/css" href="../../shared/css/vars.css"><link rel="stylesheet" type="text/css" href="../../popup/css/options.css"><link rel="stylesheet" type="text/css" href="../../popup/css/popup.css"><link rel="stylesheet" type="text/css" href="../../shared/css/loader.css"><script defer="defer" src="../../shared/min/jquery.min.js"></script><script defer="defer" src="../js/select2.min.js"></script><script defer="defer" src="../../shared/js/utils/logTrace.js"></script><script defer="defer" src="../../shared/js/utils/miniquery.js"></script><script defer="defer" src="../../shared/js/utils/config.js"></script><script defer="defer" src="../../shared/js/utils/octokit.bundle.js"></script><script defer="defer" src="../../shared/js/utils/sync.js"></script><script defer="defer" src="../../shared/js/utils/functions.js"></script><script defer="defer" src="../../shared/js/utils/data.js"></script><script defer="defer" src="../../shared/js/utils/paper.js"></script><script defer="defer" src="../../shared/js/utils/state.js"></script><script defer="defer" src="../../shared/js/utils/bibtexParser.js"></script><script defer="defer" src="../../shared/js/utils/parsers.js"></script><script defer="defer" src="../js/handlers.js"></script><script defer="defer" src="../js/templates.js"></script><script defer="defer" src="../js/memory.js"></script><script defer="defer" src="../js/popup.js"></script></head><body><div id="popup-header"><h1 title="https://papermemory.org"><a class="link-in-new-tab" href="https://papermemory.org">PaperMemory</a></h1><svg viewBox="0 0 24 24" class="pm-tabler-icon ml-3" id="header-icon"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><polyline points="13 3 13 10 19 10 11 21 11 14 5 14 13 3"/></svg></div><div id="popup-container"><div id="notArxiv" style="display: none; position: relative"><p><strong style="color: var(--lightRed)">PaperMemory</strong> automatically records and organizes the papers you read, without ever leaving your browser.</p><p>When opening a paper (its web page or pdf), a reference to that paper will be stored in your Memory. Supports Arxiv, Open Review, PNAS, Science, Nature <a href="https://papermemory.org/features/#venues" class="link-in-new-tab">and more</a>!</p><p><a class="link-in-new-tab" href="https://github.com/vict0rsch/PaperMemory/issues/13">Request a new venue</a>.</p><p class="d-flex-center-start">Click on the&nbsp;<svg xmlns="http://www.w3.org/2000/svg" tabindex="0" class="icon icon-tabler" width="22" height="22" viewBox="0 0 24 24" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 4h3l2 2h5a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2"/><path d="M17 17v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2h2"/></svg>&nbsp;Memory button below <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-down-left" width="20" height="20" viewBox="0 0 24 24" stroke-width="2" stroke="#7c7f8b" fill="none" stroke-linecap="round" stroke-linejoin="round" style="stroke-width: 2px; vertical-align: bottom"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><line x1="17" y1="7" x2="7" y2="17"/><polyline points="16 17 7 17 7 8"/></svg> <span>(or press <code>a</code></span> )!</p><p style="text-align: center"><button style="cursor: pointer" id="keyboardShortcuts" class="code-font">User Guide</button></p><div id="website-parsing-root" style="display: none; width: 100%"></div><div id="whats-new-container"><div class="d-relative"><svg width="34" height="34" viewBox="0 0 24 24" stroke-width="1" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 5a2 2 0 0 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6"/><path d="M9 17v1a3 3 0 0 0 6 0v-1"/></svg> <span id="whats-new-marker" style="display: none"></span></div></div></div><div id="isArxiv" style="display: none"><h3 style="text-align: center;
2+
@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap");</style><link rel="stylesheet" type="text/css" href="../css/select2.min.css"><link rel="stylesheet" type="text/css" href="../../shared/css/bootstrap-utilities.min.css"><link rel="stylesheet" type="text/css" href="popup.min.css"><script defer="defer" src="../../shared/min/jquery.min.js"></script><script defer="defer" src="../js/select2.min.js"></script><script defer="defer" src="../../shared/min/utils.min.js"></script><script defer="defer" src="popup.min.js"></script></head><body><div id="popup-header-empty">&nbsp;</div><div id="popup-header"><h1 title="https://papermemory.org"><a class="link-in-new-tab" href="https://papermemory.org">PaperMemory</a></h1><svg viewBox="0 0 24 24" class="pm-tabler-icon ml-3" id="header-icon"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><polyline points="13 3 13 10 19 10 11 21 11 14 5 14 13 3"/></svg></div><div id="popup-container"><div id="notArxiv" style="display: none; position: relative"><p><strong style="color: var(--lightRed)">PaperMemory</strong> automatically records and organizes the papers you read, without ever leaving your browser.</p><p>When opening a paper (its web page or pdf), a reference to that paper will be stored in your Memory. Supports Arxiv, Open Review, PNAS, Science, Nature <a href="https://papermemory.org/features/#venues" class="link-in-new-tab">and more</a>!</p><p><a class="link-in-new-tab" href="https://github.com/vict0rsch/PaperMemory/issues/13">Request a new venue</a>.</p><p class="d-flex-center-start">Click on the&nbsp;<svg xmlns="http://www.w3.org/2000/svg" tabindex="0" class="icon icon-tabler" width="22" height="22" viewBox="0 0 24 24" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 4h3l2 2h5a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2"/><path d="M17 17v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2h2"/></svg>&nbsp;Memory button below <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-down-left" width="20" height="20" viewBox="0 0 24 24" stroke-width="2" stroke="#7c7f8b" fill="none" stroke-linecap="round" stroke-linejoin="round" style="stroke-width: 2px; vertical-align: bottom"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><line x1="17" y1="7" x2="7" y2="17"/><polyline points="16 17 7 17 7 8"/></svg> <span>(or press <code>a</code></span> )!</p><p style="text-align: center"><button style="cursor: pointer" id="keyboardShortcuts" class="code-font">User Guide</button></p><div id="website-parsing-root" style="display: none; width: 100%"></div><div id="whats-new-container"><div class="d-relative"><svg width="34" height="34" viewBox="0 0 24 24" stroke-width="1" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 5a2 2 0 0 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6"/><path d="M9 17v1a3 3 0 0 0 6 0v-1"/></svg> <span id="whats-new-marker" style="display: none"></span></div></div></div><div id="isArxiv" style="display: none"><h3 style="text-align: center;
33
max-width: 95%;
44
font-weight: 400;
55
margin-bottom: 0px;

0 commit comments

Comments
 (0)