Skip to content

Commit

Permalink
fix ocr build conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ttop32 committed Feb 5, 2024
1 parent 9169427 commit ece7589
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import tippy, { sticky, hideAll } from "tippy.js";
import { encode } from "he";
import matchUrl from "match-url-wildcard";
import delay from "delay";
import browser from "webextension-polyfill";

import {
enableSelectionEndEvent,
Expand Down Expand Up @@ -746,7 +747,7 @@ function openPdfIframe(url) {
$("embed").remove();

$("<embed/>", {
src: util.getUrlExt(
src: browser.runtime.getURL(
`/pdfjs/web/viewer.html?file=${encodeURIComponent(url)}`
),
css: {
Expand Down Expand Up @@ -790,7 +791,7 @@ function injectGoogleDocAnnotation() {
return;
}
var s = document.createElement("script");
s.src = util.getUrlExt("googleDocInject.js"); //chrome.runtime.getURL("js/docs-canvas.js");
s.src = browser.runtime.getURL("googleDocInject.js"); //chrome.runtime.getURL("js/docs-canvas.js");
document.documentElement.appendChild(s);
}

Expand Down
14 changes: 9 additions & 5 deletions src/ocr/ocrIframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//3. resend result to host

import Tesseract from "tesseract.js";

import * as util from "/src/util";
import { waitUntil, WAIT_FOREVER } from "async-wait-until";
import browser from "webextension-polyfill";

var schedulerList = {};
var loadingList = {};
Expand Down Expand Up @@ -105,15 +105,19 @@ async function getScheduler(lang, mode) {
if (schedulerList[id]) {
return schedulerList[id];
} else if (loadingList[id]) {
await util.waitUntilForever(() => schedulerList[id]);
await waitUntil(() => schedulerList[id], {
timeout: WAIT_FOREVER,
});
return schedulerList[id];
}
loadingList[id] = true;

var scheduler = Tesseract.createScheduler();
var workerIndexList = mode.includes("auto") ? [0] : [0, 1, 2, 3, 4];
var workerPath = util.getUrlExt("/tesseract/worker.min.js");
var corePath = util.getUrlExt("/tesseract/tesseract-core-lstm.wasm.js");
var workerPath = browser.runtime.getURL("/tesseract/worker.min.js");
var corePath = browser.runtime.getURL(
"/tesseract/tesseract-core-lstm.wasm.js"
);

var tessedit_pageseg_mode = mode.includes("auto")
? Tesseract.PSM.AUTO_ONLY
Expand Down

0 comments on commit ece7589

Please sign in to comment.