-
Notifications
You must be signed in to change notification settings - Fork 166
/
shooter.user.js
86 lines (71 loc) · 2.7 KB
/
shooter.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
// ==UserScript==
// @id shooter@[email protected]
// @name shooter.cn 直接下载
// @version 1.6
// @namespace https://github.com/ywzhaiqi/
// @author [email protected]
// @description 在 shooter.cn 搜索页面按下载按钮直接下载。语言、发行着色。
// @include http://*shooter.cn/search*
// @include http://www.shooter.cn/xml/list/sub/*
// downloadURL https://userscripts.org/scripts/source/167084.user.js
// updateURL https://userscripts.org/scripts/source/167084.meta.js
//
// @homepageURL https://greasyfork.org/scripts/304/
// @updateURL https://greasyfork.org/scripts/304/code.meta.js
// @downloadURL https://greasyfork.org/scripts/304/code.user.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @run-at document-end
// ==/UserScript==
(function() {
var isHighlight = GM_getValue("isHighlight");
if (typeof isHighlight == 'undefined')
isHighlight = true;
var highlightXPath = '//ul[@id="sublist_ul"]/li[contains(text(), "语言")] | //span[@name="rlsitelink"]';
GM_addStyle("\
#resultsdiv { max-width: 800px !important; }\
.sublist_box_title_l { max-width: 770px !important; }\
.mHighlight {\
background-color: rgb(153, 255, 153) !important;\
}\
");
// 直接下载
var buttons = document.querySelectorAll("a#downsubbtn");
for (var i = buttons.length - 1; i >= 0; i--) {
// buttons[i].setAttribute("onclick", buttons[i].getAttribute("onclick").replace('local_downfile', 'shtgdownfile'));
buttons[i].setAttribute("href", "javascript:;");
}
setTimeout(setHighlight, 0);
// 设置着色
function setHighlight() {
if (isHighlight) {
$x(highlightXPath).forEach(function(e) {
e.classList.add("mHighlight");
});
GM_registerMenuCommand("取消射手网着色?", toggleHighlight);
} else {
GM_registerMenuCommand("设置射手网着色?", toggleHighlight);
}
}
function toggleHighlight() {
isHighlight = !isHighlight;
GM_setValue("isHighlight", isHighlight);
window.location.reload();
}
function $x(aXPath, aContext) {
var nodes = [];
var doc = document;
var aContext = aContext || doc;
try {
var results = doc.evaluate(aXPath, aContext, null,
XPathResult.ANY_TYPE, null);
var node;
while (node = results.iterateNext()) {
nodes.push(node);
}
} catch (ex) {}
return nodes;
}
})();