aboutsummaryrefslogtreecommitdiffstats
path: root/src/background
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-31 19:22:37 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-07-31 19:22:37 +0530
commit4e198684d1af16ed4c21fd64d2ec1cd78b72c602 (patch)
treea47448649d823aa30b67d5f140faf2ab78f0bf50 /src/background
parent3dc5590d7be021140e984407766bca3e3a9b4d82 (diff)
downloadbanglar-bhumi-utils-4e198684d1af16ed4c21fd64d2ec1cd78b72c602.tar.gz
banglar-bhumi-utils-4e198684d1af16ed4c21fd64d2ec1cd78b72c602.zip
feat: removed ocr
- After the latest updates on the banglarbhumi.gov.in website the captcha has been changed to a question based captcha
Diffstat (limited to 'src/background')
-rw-r--r--src/background/run-ocr.ts49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/background/run-ocr.ts b/src/background/run-ocr.ts
deleted file mode 100644
index 683f701..0000000
--- a/src/background/run-ocr.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { OCRRequest, OCRResponse } from "@/shared/ocr-request";
-
-const OFFSCREEN_DOCUMENT_PATH = "offscreen/ocr/index.html";
-
-// Function to ensure the offscreen document is open
-/**
- * Ensures the offscreen OCR document is open. If it already exists
- * this is a no-op.
- */
-async function setupOffscreenDocument(): Promise<void> {
- if (await chrome.offscreen.hasDocument()) {
- return; // Offscreen document already open
- }
- await chrome.offscreen.createDocument({
- url: OFFSCREEN_DOCUMENT_PATH,
- reasons: [chrome.offscreen.Reason.CLIPBOARD],
- justification: "Performing OCR with Tesseract.js in a long-running context."
- });
-}
-
-// Listen for messages from content scripts (and popup if applicable)
-/**
- * Listens for `"OCR"` messages from content scripts. Forwards the
- * image data URL to an offscreen document for Tesseract.js processing
- * and sends the recognised text back to the caller.
- */
-chrome.runtime.onMessage.addListener(function(message: OCRRequest, _sender, sendResponse): boolean {
- if (message.type === "OCR" && message.dataURL) {
- void (async function(): Promise<void> {
- try {
- // Ensure the offscreen document is open
- await setupOffscreenDocument();
-
- // Send the OCR request to the offscreen document
- const offscreenResponse = await chrome.runtime.sendMessage<OCRRequest, OCRResponse>({
- type: "OFFSCREEN_OCR_REQUEST",
- dataURL: message.dataURL
- });
-
- sendResponse(offscreenResponse);
- } catch(error) {
- sendResponse({ success: false, error: (error as Error).message });
- }
- })();
- return true; // Indicate async response
- }
-
- return false;
-});