2018-05-15 09:21:03 +00:00
|
|
|
// ==UserScript==
|
|
|
|
// @name WebIDE增强脚本
|
|
|
|
// @namespace http://ide.yumc.pw/
|
2018-05-15 10:08:39 +00:00
|
|
|
// @version 0.5
|
2018-05-15 09:21:03 +00:00
|
|
|
// @description Coding WebIDE 增强脚本
|
|
|
|
// @author MiaoWoo
|
|
|
|
// @match http*://ide.yumc.pw/ws/*
|
2018-05-15 09:24:03 +00:00
|
|
|
// @match http*://ide.coding.net/ws/*
|
2018-05-15 09:21:03 +00:00
|
|
|
// @grant none
|
|
|
|
// ==/UserScript==
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
2018-05-15 09:34:39 +00:00
|
|
|
var id = setInterval(function (){
|
|
|
|
if (document.getElementsByClassName('ide-container')[0]) {
|
2018-05-15 09:54:42 +00:00
|
|
|
window.onbeforeunload = function () { return false; }
|
2018-05-15 09:34:39 +00:00
|
|
|
console.log('已阻止 Ctrl + W 关闭页面...')
|
|
|
|
clearInterval(id);
|
|
|
|
}
|
|
|
|
}, 300)
|
2018-05-15 09:52:24 +00:00
|
|
|
document.onkeydown = function() {
|
2018-05-15 09:49:59 +00:00
|
|
|
var e = window.event;
|
2018-05-15 10:08:39 +00:00
|
|
|
if (e.altKey) {
|
|
|
|
switch (e.keyCode) {
|
|
|
|
case 87:
|
|
|
|
// Alt + W 关闭Tab标签页
|
|
|
|
var activeTab = document.getElementsByClassName('tab-label active')[0];
|
|
|
|
if (activeTab) {
|
|
|
|
activeTab.childNodes[2].childNodes[0].click();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 81:
|
|
|
|
// Alt + Q 切换Tab标签页
|
|
|
|
var currectTab = document.getElementsByClassName('tab-label active')[0];
|
|
|
|
if (currectTab) {
|
|
|
|
var tab;
|
|
|
|
if (currectTab.nextElementSibling) {
|
|
|
|
tab = currectTab.nextElementSibling;
|
|
|
|
} else {
|
|
|
|
tab = document.getElementsByClassName('tab-label')[0];
|
|
|
|
}
|
|
|
|
if (tab) {
|
|
|
|
tab.click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2018-05-15 09:21:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|