forked from AirBashX/UserScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsAssistant.user.js
71 lines (68 loc) · 2.3 KB
/
JenkinsAssistant.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
// ==UserScript==
// @name Jenkins助手
// @author airbash
// @version 0.0.1
// @namespace airbash/JenkinsAssistant
// @homepageURL https://github.com/AirBashX/UserScript
// @description 过滤健康程度低、不经常更新的jenkins插件
// @match *://plugins.jenkins.io/ui/search*
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @icon https://www.jenkins.io/favicon.ico
// @run-at document-end
// @license GPL-3.0
// ==/UserScript==
///<reference path="./tampermonkey-reference.d.ts" />
(function () {
"use strict";
let inter = setInterval(() => {
let CategoryList = document.querySelector(".CategoryList");
if (CategoryList) {
let li = document.createElement("li");
li.className = "Other";
//<label class="exclude"><input type="checkbox" name="Other" value="Other" /><span>健康度</span></label><ul><li><label class="exclude"><input type="checkbox" name="health" value="health" /><span>优秀</span></label></li></ul>
li.innerHTML = '<ul><li><label class="exclude"><input type="checkbox" name="health" value="health" /><span>优秀</span></label></li></ul>';
CategoryList.prepend(li);
let health = document.querySelector("[name=health]");
let display = GM_getValue("display", false);
health.checked = display;
saerchHandler(health)
checkedHandler(health);
health.addEventListener("change", function () {
checkedHandler(health);
});
clearInterval(inter);
}
}, 10000);
function saerchHandler(health) {
let button = document.querySelectorAll(".btn-primary");
button[1].onclick = function () {
health.checked=false;
GM_setValue("display", false);
};
let items = document.querySelectorAll(".headerContainer label:not(.exclude),[name=showAll]");
for (let item of items) {
item.onclick=function(){
health.checked=false;
GM_setValue("display", false);
}
}
}
function checkedHandler(health) {
let items = document.querySelectorAll(".SearchResults--ItemBox");
if (health.checked) {
for (let item of items) {
if (item.querySelector(".bg-warning,.bg-danger")) {
GM_setValue("display", true);
item.style.display = "none";
}
}
} else {
for (let item of items) {
GM_setValue("display", false);
item.style.display = "unset";
}
}
}
})();