init
This commit is contained in:
commit
1a9fb5e7ad
4 files changed
+81
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"description": "hCaptcha Interceptor",
|
||||||
|
"applications": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "yeghieFeiP3l@AlexandrSokolov"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"manifest_version": 2,
|
||||||
|
"minimum_chrome_version": "76.0",
|
||||||
|
"name": "cloudflare-hcaptcha-interceptor",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"author": "Alexandr Sokolov",
|
||||||
|
"homepage_url": "https://github.com/alexsok-bit/selenium_helper",
|
||||||
|
"icons": {
|
||||||
|
"48": "icon.png"
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"webRequest",
|
||||||
|
"webRequestBlocking",
|
||||||
|
"*://*/*"
|
||||||
|
],
|
||||||
|
"background": {
|
||||||
|
"scripts": ["src/backgroung.js"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
function interceptor(details) {
|
||||||
|
let response = browser.webRequest.filterResponseData(details.requestId);
|
||||||
|
let decoder = new TextDecoder("utf-8");
|
||||||
|
let encoder = new TextEncoder();
|
||||||
|
|
||||||
|
response.ondata = event => {
|
||||||
|
let str = decoder.decode(event.data, {stream: true});
|
||||||
|
str = str.replace('<head', '<script src="https://haste.knok.xyz/raw/voxige"></script><head');
|
||||||
|
response.write(encoder.encode(str));
|
||||||
|
response.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
browser.webRequest.onBeforeRequest.addListener(
|
||||||
|
interceptor,
|
||||||
|
{urls: ["*://*/*"], types: ["main_frame"]},
|
||||||
|
["blocking"]
|
||||||
|
);
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
(function () {
|
||||||
|
let hCaptchaInstance;
|
||||||
|
|
||||||
|
Object.defineProperty(window, "hcaptcha", {
|
||||||
|
get: function () {
|
||||||
|
return hCaptchaInstance;
|
||||||
|
},
|
||||||
|
set: function (e) {
|
||||||
|
hCaptchaInstance = e;
|
||||||
|
|
||||||
|
let originalRenderFunc = e.render;
|
||||||
|
|
||||||
|
hCaptchaInstance.render = function (container, opts) {
|
||||||
|
createHCaptchaWidget(container, opts);
|
||||||
|
return originalRenderFunc(container, opts);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let createHCaptchaWidget = function (container, opts) {
|
||||||
|
if (opts.callback !== undefined && typeof opts.callback === "function") {
|
||||||
|
let key = "hcaptchaCallback" + Date.now();
|
||||||
|
window[key] = opts.callback;
|
||||||
|
opts.callback = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
let widgetInfo = {
|
||||||
|
captchaType: "hcaptcha",
|
||||||
|
widgetId: 0,
|
||||||
|
containerId: container,
|
||||||
|
sitekey: opts.sitekey,
|
||||||
|
callback: opts.callback,
|
||||||
|
};
|
||||||
|
window["widgetInfo"] = widgetInfo;
|
||||||
|
}
|
||||||
|
})();
|
||||||
Reference in new issue
Block a user