15 lines
586 B
JavaScript
15 lines
586 B
JavaScript
/**
|
|
* Content script: bridges native host events to the page and subscribes to tunnel events.
|
|
*/
|
|
|
|
const browser = typeof chrome !== 'undefined' && chrome.runtime?.sendMessage ? chrome : typeof browser !== 'undefined' ? browser : chrome;
|
|
|
|
// Subscribe to native host events (tunnel ready/closed/error, etc.)
|
|
browser.runtime.sendMessage({ target: 'holesail-native', action: 'subscribe' }, () => {});
|
|
|
|
browser.runtime.onMessage.addListener((message) => {
|
|
if (message.type === 'holesail-host-disconnect') {
|
|
window.dispatchEvent(new CustomEvent('holesail-host-disconnect'));
|
|
}
|
|
});
|