mirror of https://github.com/dessant/buster
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
814 B
JavaScript
29 lines
814 B
JavaScript
function initReset(challengeUrl) {
|
|
const script = document.createElement('script');
|
|
script.onload = function (ev) {
|
|
ev.target.remove();
|
|
document.dispatchEvent(
|
|
new CustomEvent('___resetCaptcha', {detail: challengeUrl})
|
|
);
|
|
};
|
|
script.src = chrome.runtime.getURL('/src/content/reset.js');
|
|
document.documentElement.appendChild(script);
|
|
}
|
|
|
|
function addListener() {
|
|
const onMessage = function (request) {
|
|
if (request.id === 'resetCaptcha') {
|
|
removeCallbacks();
|
|
initReset(request.challengeUrl);
|
|
}
|
|
};
|
|
|
|
const removeCallbacks = function () {
|
|
window.clearTimeout(timeoutId);
|
|
chrome.runtime.onMessage.removeListener(onMessage);
|
|
};
|
|
const timeoutId = window.setTimeout(removeCallbacks, 10000); // 10 seconds
|
|
|
|
chrome.runtime.onMessage.addListener(onMessage);
|
|
}
|