forked from NopeCHALLC/nopecha-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hcaptcha_language.js
37 lines (31 loc) · 1012 Bytes
/
hcaptcha_language.js
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
/**
* Sets the hCaptcha language to English.
*/
(() => {
const TARGET_LANG = 'en';
let observer;
function scan_head() {
const current_language = navigator.language.split('-')[0];
for (const $e of document.querySelectorAll(`script[src*="hcaptcha.com/1/api.js"]`)) {
// observer.disconnect();
const url = new URL($e.src);
const lang = url.searchParams.get('hl') || current_language;
if (lang === TARGET_LANG) {
continue;
}
url.searchParams.set('hl', TARGET_LANG);
$e.src = url.toString();
}
}
observer = new MutationObserver(scan_head);
// Wait for head
setTimeout(() => {
scan_head();
observer.observe(document.head, {childList: true});
// // Stop observer timeout
// setTimeout(() => {
// observer.disconnect();
// console.log('disconnected observer');
// }, 1000 * 60);
}, 0);
})();