diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2025-06-13 18:36:30 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2025-06-13 18:36:30 +0530 |
| commit | 00e5ea80b1b0ba37ac4b5dc7b10ae6eac26aa1af (patch) | |
| tree | 1e617e90588571988ae4580390cac619bc9d80f8 | |
| parent | bce4cff7f7144bc91d780e2dd2f8e1114109f407 (diff) | |
| download | banglar-bhumi-utils-00e5ea80b1b0ba37ac4b5dc7b10ae6eac26aa1af.tar.gz banglar-bhumi-utils-00e5ea80b1b0ba37ac4b5dc7b10ae6eac26aa1af.zip | |
Successfully communicating between background script and content scripts.
| -rw-r--r-- | src/background/run-ocr.ts | 8 | ||||
| -rw-r--r-- | src/background/second-script.ts | 1 | ||||
| -rw-r--r-- | src/scripts.json | 4 | ||||
| -rw-r--r-- | src/scripts/login/index.ts | 7 |
4 files changed, 11 insertions, 9 deletions
diff --git a/src/background/run-ocr.ts b/src/background/run-ocr.ts index d0af073..d61e71a 100644 --- a/src/background/run-ocr.ts +++ b/src/background/run-ocr.ts @@ -1 +1,7 @@ -console.log("THIS IS A BACKGROUND script."); +chrome.runtime.onMessage.addListener(async (message, sender, sendResponse) => { + if (message.type === "ping") { + console.log("Received ping from content script"); + console.log(message.data); + sendResponse({ text: "pong" }); + } +}); diff --git a/src/background/second-script.ts b/src/background/second-script.ts deleted file mode 100644 index 9e3a621..0000000 --- a/src/background/second-script.ts +++ /dev/null @@ -1 +0,0 @@ -console.log("THiS IS THE SECOND SCRIPT"); diff --git a/src/scripts.json b/src/scripts.json index 74a465d..715ad4d 100644 --- a/src/scripts.json +++ b/src/scripts.json @@ -1,7 +1,6 @@ { "injected": { "stop-blocking.ts": "*", - "login/index.ts": "*", "otps/grievance-application.ts": "GrievAppViewAction.action", "otps/mutation-application.ts": "MuteApplication.action", "otps/warish-application.ts": "WarishAppViewAction.action", @@ -10,5 +9,8 @@ "captcha/know-your-property.ts": "KnowYourProperty.action", "captcha/application-receipt.ts": "Apprecrep.action", "functionality/sheet-map/index.ts": "SheetMapViewAction.action" + }, + "after": { + "login/index.ts": "*" } } diff --git a/src/scripts/login/index.ts b/src/scripts/login/index.ts index adbcdbc..dacc90a 100644 --- a/src/scripts/login/index.ts +++ b/src/scripts/login/index.ts @@ -84,12 +84,7 @@ const observer = new MutationObserver((mutationsList, obs) => { prepareCaptcha(ctx, canvas.width, canvas.height); canvas.style.display = ""; const dataURL = canvas.toDataURL("image/png"); - Tesseract.recognize(canvas, 'eng', { - logger: console.log - }).then(({ data: { text, confidence } }) => { - console.log("OCR Result:", text); - console.log("OCR confidence:", confidence); - }); + chrome.runtime.sendMessage({ type: "ping", data: "hello background" }).then(console.log); // TODO: Perform OCR // window.postMessage({ // type: "RUN_OCR", |
