完成扩展
This commit is contained in:
42
extension/content/modules/extension-wrapper-template.js
Normal file
42
extension/content/modules/extension-wrapper-template.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user