Skip to content

Commit

Permalink
feat(webview): handle window.open
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Jan 31, 2025
1 parent c037255 commit ae5e8eb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/stremio_app/stremio_wevbiew/wevbiew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,23 @@ impl PartialUi for WebView {
}
})
}catch(e){}
window.open = (url) => {
if (typeof url === 'string' && URL.canParse(url))
return console.error('Not a valid URL string');
try {
const message = {
id: 1,
args: ['open-external', url],
};
window.chrome.webview.postMessage(JSON.stringify(message));
} catch(e) {
console.error('Failed to post message');
}
};
try{console.log('Shell JS injected');if(window.self === window.top) {
window.qt={webChannelTransport:{send:window.chrome.webview.postMessage}};
window.chrome.webview.addEventListener('message',ev=>window.qt.webChannelTransport.onmessage(ev));
Expand Down

0 comments on commit ae5e8eb

Please sign in to comment.