-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
46 lines (39 loc) · 1.25 KB
/
content.js
File metadata and controls
46 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function applyAntiFingerprinting() {
try {
Object.defineProperty(navigator, 'webdriver', { get: () => true });
Object.defineProperty(navigator, 'plugins', { get: () => [] });
Object.defineProperty(navigator, 'mimeTypes', { get: () => [] });
Object.defineProperty(navigator, 'platform', { get: () => 'Android-x86_64' });
HTMLCanvasElement.prototype.toDataURL = function () {
return "data:image/png;base64,";
};
} catch (e) {
}
}
function detectCaptcha() {
const patterns = [
/captcha/i,
/g-recaptcha/i,
/hcaptcha/i,
/data-sitekey/i,
/cf-captcha/i
];
const bodyText = document.body.innerHTML;
const found = patterns.some((pattern) => pattern.test(bodyText));
console.log("[Content] CAPTCHA detected?", found);
return found;
}
function runWhenReady(antiFingerprintingEnabled) {
if (antiFingerprintingEnabled) applyAntiFingerprinting();
if (document.body) {
if (detectCaptcha()) {
browser.runtime.sendMessage({ type: "captcha_detected" })
}
} else {
setTimeout(() => runWhenReady(antiFingerprintingEnabled), 100);
}
}
browser.storage.local.get("antiFingerprintingEnabled").then((data) => {
const enabled = data.antiFingerprintingEnabled !== false;
runWhenReady(enabled);
});