From dec2f624e5bacfe3c73e0fa1c0eaa22eda3d01b6 Mon Sep 17 00:00:00 2001 From: Shiva Prasad Date: Sat, 22 Oct 2022 16:35:08 +0530 Subject: [PATCH] Gh-pages for live demo viewer --- src/pdfjs | 2 +- src/scripts/extension.js | 8 ++----- src/scripts/mv2/page-script.js | 38 +++++++--------------------------- 3 files changed, 11 insertions(+), 37 deletions(-) diff --git a/src/pdfjs b/src/pdfjs index e59479a..2d512bf 160000 --- a/src/pdfjs +++ b/src/pdfjs @@ -1 +1 @@ -Subproject commit e59479ac00c11fe096039f2f4c093c933ef72ce3 +Subproject commit 2d512bfb0e88d8cc01edd9e6a937f79fdfa85f76 diff --git a/src/scripts/extension.js b/src/scripts/extension.js index 0a0a8e0..9e19852 100644 --- a/src/scripts/extension.js +++ b/src/scripts/extension.js @@ -1,8 +1,4 @@ /* Load extension scripts and add-on into the viewer page */ -if (window.location.protocol === "moz-extension:") { - import("./mv2/page-script.js"); -} else { - import("./mv3/page-script.js"); -} +import "./mv2/page-script.js"; import "./doqment.js"; -import "/doq/addon/doq.js"; +import "../doq/addon/doq.js"; diff --git a/src/scripts/mv2/page-script.js b/src/scripts/mv2/page-script.js index 3f79543..f6bc0e0 100644 --- a/src/scripts/mv2/page-script.js +++ b/src/scripts/mv2/page-script.js @@ -1,44 +1,22 @@ -import { getPdfUrl, addLink, execOnEvent, isTouchScreen } from "../utils.js"; +import { addLink, execOnEvent } from "../utils.js"; /* Rebranding */ document.title = "doqment PDF Reader"; -const favIcon = addLink("icon", "/images/icon32.png"); +const favIcon = addLink("icon", "../../images/icon32.png"); -/* Display host website favicon (if available) */ -const pdfUrl = getPdfUrl(); -if (self === top && pdfUrl?.startsWith("http")) { - const origIcon = new URL(pdfUrl).origin + "/favicon.ico"; - fetch(origIcon, {method: "HEAD"}).then(resp => { - if (resp.ok && resp.headers.get("content-type")?.includes("image/")) - favIcon.href = origIcon; - }); - browser.tabs.getCurrent().then(tab => { - browser.pageAction.show(tab.id); - }); -} - -/* Make Firefox the pre-selected color scheme */ -function selectFirefox() { - /* scheme = 0 because of the migration code in doq */ - const pref = JSON.stringify({ scheme: 0 }); +/* Make Solarized the pre-selected color scheme */ +function selectSolarized() { + /* scheme = 3 because of the migration code in doq */ + let pref = JSON.stringify({ scheme: 3, tone: "1" }); localStorage.setItem("doq.preferences.light", pref); + pref = JSON.stringify({ scheme: 3, tone: "2" }); localStorage.setItem("doq.preferences.dark", pref); } -/* Disable the annotation editors by default on mobile */ -async function disableAnnotEditors() { - const platform = await browser.runtime.getPlatformInfo(); - if (platform.os === "android" && isTouchScreen()) { - const app = window.PDFViewerApplication; - app.preferences.set("annotationEditorMode", -1); - } -} - /* Disable hardware accelerated rendering of canvas */ function forceSoftwareRender() { const doqOptions = { softwareRender: true }; localStorage.setItem("doq.options", JSON.stringify(doqOptions)); } -execOnEvent("init", [selectFirefox, disableAnnotEditors]) -execOnEvent("update-0.9", [forceSoftwareRender]) +execOnEvent("init", [selectSolarized, forceSoftwareRender])