支持外跳浏览器打开

This commit is contained in:
Tw93
2022-11-15 19:27:55 +08:00
parent 4c8eb3cc67
commit b6d71531b3
4 changed files with 32 additions and 2 deletions

View File

@@ -1,5 +1,3 @@
// @ts-check
/**
* @typedef {string} KeyboardKey `event.key` 的代号,
* 见 <https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values>
@@ -133,6 +131,11 @@ window.addEventListener('DOMContentLoaded', (_event) => {
const href = origin.href;
if (href) {
origin.target = '_self';
//额外处理下 twitter 的外跳,对于其他需要外跳的可以改这里成对应域名
if(location.host === "twitter.com" && href.indexOf("twitter.com")===-1){
e.preventDefault();
window.ipc.postMessage(`open_browser:${href}`);
}
}
});
});