-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
11 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) |