From 976ae51dabe77686e405a2b99127485209c7c9cd Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Fri, 13 Jun 2025 17:31:17 +0530 Subject: Adding a flake.nix. Cleaning up the captcha for the OCR. --- src/scripts.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/scripts.json') diff --git a/src/scripts.json b/src/scripts.json index 43d506c..74a465d 100644 --- a/src/scripts.json +++ b/src/scripts.json @@ -1,7 +1,7 @@ { "injected": { "stop-blocking.ts": "*", - "login.ts": "*", + "login/index.ts": "*", "otps/grievance-application.ts": "GrievAppViewAction.action", "otps/mutation-application.ts": "MuteApplication.action", "otps/warish-application.ts": "WarishAppViewAction.action", -- cgit v1.2.3 From 00e5ea80b1b0ba37ac4b5dc7b10ae6eac26aa1af Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Fri, 13 Jun 2025 18:36:30 +0530 Subject: Successfully communicating between background script and content scripts. --- src/background/run-ocr.ts | 8 +++++++- src/background/second-script.ts | 1 - src/scripts.json | 4 +++- src/scripts/login/index.ts | 7 +------ 4 files changed, 11 insertions(+), 9 deletions(-) delete mode 100644 src/background/second-script.ts (limited to 'src/scripts.json') 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", -- cgit v1.2.3