mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-03-11 17:15:49 +00:00
Merge pull request #15 from Stremio/feat/webview-handle-window-open
feat(webview): handle window.open
This commit is contained in:
commit
38d52a3c6a
1 changed files with 18 additions and 0 deletions
|
|
@ -137,6 +137,24 @@ impl PartialUi for WebView {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
|
|
||||||
|
window.open = (url) => {
|
||||||
|
if (typeof url === 'string' && URL.canParse(url)) {
|
||||||
|
try {
|
||||||
|
const message = {
|
||||||
|
id: 1,
|
||||||
|
args: ['open-external', url],
|
||||||
|
};
|
||||||
|
|
||||||
|
window.chrome.webview.postMessage(JSON.stringify(message));
|
||||||
|
} catch(e) {
|
||||||
|
console.error('Failed to post message');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return console.error('Not a valid URL string');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
try{console.log('Shell JS injected');if(window.self === window.top) {
|
try{console.log('Shell JS injected');if(window.self === window.top) {
|
||||||
window.qt={webChannelTransport:{send:window.chrome.webview.postMessage}};
|
window.qt={webChannelTransport:{send:window.chrome.webview.postMessage}};
|
||||||
window.chrome.webview.addEventListener('message',ev=>window.qt.webChannelTransport.onmessage(ev));
|
window.chrome.webview.addEventListener('message',ev=>window.qt.webChannelTransport.onmessage(ev));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue