43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
/**
|
|
* Extension Compatibility Wrapper
|
|
* Add this to the end of each module file to make it work with the extension
|
|
*/
|
|
|
|
// Listen for initialization messages from content script
|
|
window.addEventListener('message', (event) => {
|
|
if (event.source !== window) return;
|
|
|
|
const message = event.data;
|
|
|
|
// Handle module initialization
|
|
if (message && message.type === 'INIT_MODULE' && message.moduleName === 'hcaptchaBypass') {
|
|
console.log('[HCaptcha Bypass] Initializing from extension...');
|
|
|
|
if (window[message.instanceKey]) {
|
|
console.log('[HCaptcha Bypass] Instance already exists');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const instance = new HCaptchaBypassModule(message.config);
|
|
instance.init();
|
|
window[message.instanceKey] = instance;
|
|
console.log('[HCaptcha Bypass] Initialized successfully');
|
|
} catch (error) {
|
|
console.error('[HCaptcha Bypass] Initialization failed:', error);
|
|
}
|
|
}
|
|
|
|
// Handle module destruction
|
|
if (message && message.type === 'DESTROY_MODULE' && message.instanceKey === '__hcaptchaBypassInstance') {
|
|
console.log('[HCaptcha Bypass] Destroying instance...');
|
|
|
|
const instance = window[message.instanceKey];
|
|
if (instance && typeof instance.destroy === 'function') {
|
|
instance.destroy();
|
|
delete window[message.instanceKey];
|
|
console.log('[HCaptcha Bypass] Destroyed successfully');
|
|
}
|
|
}
|
|
});
|