-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
sjtu-automata.user.js
103 lines (93 loc) · 3.77 KB
/
sjtu-automata.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// ==UserScript==
// @name sjtu-automata
// @namespace http://tampermonkey.net/
// @version 1.3
// @description show classid under classname.
// @author MXWXZ
// @match *://i.sjtu.edu.cn/xsxk/zzxkyzb_cxZzxkYzbIndex.html*
// @match *://i.sjtu.edu.cn/design/viewFunc_cxDesignFuncPageIndex.html*
// @homepageURL https://github.com/MXWXZ/sjtu-automata/
// @supportURL https://github.com/MXWXZ/sjtu-automata/issues/
// @downloadURL https://raw.githubusercontent.com/MXWXZ/sjtu-automata/master/sjtu-automata.user.js
// @updateURL https://raw.githubusercontent.com/MXWXZ/sjtu-automata/master/sjtu-automata.user.js
// @grant none
// ==/UserScript==
function waitForKeyElements(selectorTxt, actionFunction, bWaitOnce, iframeSelector) {
var targetNodes, btargetsFound;
if (typeof iframeSelector == "undefined")
targetNodes = jQuery(selectorTxt);
else
targetNodes = jQuery(iframeSelector).contents()
.find(selectorTxt);
if (targetNodes && targetNodes.length > 0) {
btargetsFound = true;
targetNodes.each(function () {
var jThis = jQuery(this);
var alreadyFound = jThis.data('alreadyFound') || false;
if (!alreadyFound) {
var cancelFound = actionFunction(jThis);
if (cancelFound)
btargetsFound = false;
else
jThis.data('alreadyFound', true);
}
});
}
else {
btargetsFound = false;
}
var controlObj = waitForKeyElements.controlObj || {};
var controlKey = selectorTxt.replace(/[^\w]/g, "_");
var timeControl = controlObj[controlKey];
if (btargetsFound && bWaitOnce && timeControl) {
clearInterval(timeControl);
delete controlObj[controlKey]
}
else {
if (!timeControl) {
timeControl = setInterval(function () {
waitForKeyElements(selectorTxt,
actionFunction,
bWaitOnce,
iframeSelector
);
}, 300);
controlObj[controlKey] = timeControl;
}
}
waitForKeyElements.controlObj = controlObj;
}
function showid(node) {
node.children('.jxbmc').append('<br><button type="button" class="btn btn-primary btn-sm" onclick="copyid(this)">复制ID</button>');
}
function showid2(node) {
node.show();
}
(function () {
'use strict';
if (location.href.indexOf("zzxkyzb_cxZzxkYzbIndex") > -1) {
var script = document.createElement("script");
script.type = "text/javascript";
script.appendChild(document.createTextNode("function copyid(t) {const el = document.createElement('textarea');el.value =t.parentNode.parentNode.childNodes[2].innerHTML+' '+t.parentNode.parentNode.childNodes[1].innerHTML;document.body.appendChild(el);el.select();document.execCommand('copy');document.body.removeChild(el);alert(\"copy ok\");}"));
document.body.appendChild(script);
let node = $('.nav.nav-tabs.sl_nav_tabs li');
node.each(function () {
let str = $(this).children('a')[0].getAttribute("onclick");
let pos1 = str.indexOf("this,'");
let pos2 = str.indexOf("','");
$(this).append('<p>' + str.substr(str.indexOf("this,'") + 6, pos2 - pos1 - 6) + ' </p>');
});
waitForKeyElements('.body_tr', showid, false);
}
/*
To be fix
else if(location.href.indexOf("viewFunc_cxDesignFuncPageIndex") > -1) {
$('[id$=_jxb_id]').show();
$('[id$=_jxb_id]').css('width','270px');
let row=$('.jqgfirstrow').children('td:eq(1)');
row.show();
row.css('width','270px');
waitForKeyElements("[aria-describedby$='_jxb_id']", showid2, false);
}
*/
})();