Skip to content

Commit

Permalink
New branch for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
chungym committed Dec 22, 2021
1 parent ebde4c7 commit 3926671
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 175 deletions.
2 changes: 1 addition & 1 deletion background.html
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<title>Background Page</title>
<script src="js/tesseract.min.js"></script>
<script src="js/opencv.js"></script>
<script src="https://docs.opencv.org/4.5.4/opencv.js"></script>
<script src="js/background.js"></script>
</head>
<body>
Expand Down
12 changes: 9 additions & 3 deletions js/background.js
Expand Up @@ -4,6 +4,7 @@ console.log("bg script");
var scheduler;
const { createWorker, createScheduler } = Tesseract;

var loader_ready = false;

chrome.runtime.onInstalled.addListener(async () => {

Expand Down Expand Up @@ -42,7 +43,10 @@ function handleMessage(message, sender, sendResponse) {
break

case "BG_fetch":
fetchImg(message.data, sender.tab.id);
if (loader_ready)
{
fetchImg(message.data, sender.tab.id);
}
break

case "BG_recognize_bubble":
Expand Down Expand Up @@ -71,9 +75,9 @@ function loadWorkers(){

option = {
workerPath: 'js/worker.min.js',
langPath: 'traineddata',
langPath: 'https://tessdata.projectnaptha.com/4.0.0_best',
corePath: 'js/tesseract-core.wasm.js',
cacheMethod: 'none',
cacheMethod: 'write',
// CRITICAL (Content Security Policy): workerBlobURL must be set to false
// The page's settings blocked the loading of a resource at blob:moz-extension:// .../... ("script-src").
// Check: spawnWorker.js
Expand Down Expand Up @@ -110,6 +114,7 @@ function loadWorkers(){
}

await chrome.storage.local.set({load_busy: false});
loader_ready = true;
console.log('worker loaded');

})();
Expand All @@ -119,6 +124,7 @@ function loadWorkers(){

function terminateWorkers(){

loader_ready = false;
(async () => {

await chrome.storage.local.set({load_busy: true});
Expand Down
48 changes: 0 additions & 48 deletions js/opencv.js

This file was deleted.

120 changes: 0 additions & 120 deletions js/tesseract-core.asm.js

This file was deleted.

2 changes: 1 addition & 1 deletion manifest.json
Expand Up @@ -2,7 +2,7 @@
"name": "Manga JS Translator",
"version": "1.0",
"manifest_version": 2,
"content_security_policy": "script-src 'self' 'unsafe-eval' blob:; object-src 'self'",
"content_security_policy": "script-src 'self' 'unsafe-eval' https://docs.opencv.org blob:; object-src 'self'",
"permissions": [
"tabs",
"storage",
Expand Down
3 changes: 1 addition & 2 deletions popup.css
@@ -1,6 +1,5 @@
html, body {
body {
width: 250px;
height: 100px;
margin: 0;
padding: 0;
}
Expand Down
Binary file removed traineddata/jpn_vert.traineddata.gz
Binary file not shown.

0 comments on commit 3926671

Please sign in to comment.