mirror of https://github.com/jumpserver/jumpserver
perf: 优化 chrome 插件
parent
5edacf369b
commit
50d8389fff
|
@ -11,6 +11,13 @@ chrome.tabs.onCreated.addListener(function (tab) {
|
|||
});
|
||||
});
|
||||
|
||||
document.addEventListener("contextmenu", function (event) {
|
||||
event.preventDefault();
|
||||
// 监听窗口的创建事件
|
||||
chrome.windows.onCreated.addListener(function (window) {
|
||||
// 获取当前所有窗口
|
||||
chrome.windows.getAll(function (windows) {
|
||||
// 如果当前窗口数量大于1,则关闭新创建的窗口
|
||||
if (windows.length > 1) {
|
||||
chrome.windows.remove(window.id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,16 +8,29 @@ for (let i = 0; i < links.length; i++) {
|
|||
links[i].target = '_self'; // 将 target 属性设置为 _self,当前窗口打开
|
||||
}
|
||||
|
||||
|
||||
chrome.runtime.onMessage.addListener(
|
||||
function (request, sender, sendResponse) {
|
||||
console.log(request.url);
|
||||
$("iframe").attr("src", request.url);
|
||||
sendResponse({farewell: "goodbye"});
|
||||
}
|
||||
)
|
||||
|
||||
document.addEventListener("contextmenu", function (event) {
|
||||
console.log('On contextmenu event')
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
var AllowedKeys = ['P', 'F', 'p', 'f']
|
||||
window.addEventListener("keydown", function (e) {
|
||||
if (e.key === "F12" || (e.ctrlKey && !AllowedKeys.includes(e.key))) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
console.log('Press key: ', e.ctrlKey ? 'Ctrl' : '', e.shiftKey ? ' Shift' : '', e.key)
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
||||
chrome.runtime.sendMessage({greeting: "hello"}, function (response) {
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue