-
Notifications
You must be signed in to change notification settings - Fork 0
/
将灵出征聚宝提醒.user.js
63 lines (60 loc) · 2.47 KB
/
将灵出征聚宝提醒.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
// ==UserScript==
// @name 将灵出征聚宝提醒
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description 代码杀,我爱杀!
// @author DaiMaSha
// @match *://*/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM.getValue
// @grant GM.setValue
// @grant GM_notification
// ==/UserScript==
//自动复制代码
window.onclick = function() {
if (window.location.host === "web.sanguosha.com" && localStorage.getItem("elfReminder") !== null && localStorage.getItem("elfReminder") !== JSON.stringify([])) {
GM.getValue("elfReminder").then(function (reminder) {
if (typeof reminder !== "undefined") {
var elfList = JSON.parse(reminder);
if (elfList.length !== 0) {
elfList = elfList.concat(JSON.parse(localStorage.getItem("elfReminder")));
} else {
elfList = JSON.parse(localStorage.getItem("elfReminder"));
}
GM.setValue("elfReminder", JSON.stringify(elfList));
localStorage.setItem("elfReminder", JSON.stringify([]));
} else {
GM.setValue("elfReminder", localStorage.getItem("elfReminder"));
localStorage.setItem("elfReminder", JSON.stringify([]));
}
});
}
};
window.onload = () => {
GM.getValue("elfReminder").then(function(reminder){
if (typeof reminder !== "undefined"){
var currTime = Math.round((new Date()).getTime() / 1000);
var elfList = JSON.parse(reminder);
console.log(elfList.length);
if (elfList.length !== 0){
var leftReminder = [];
elfList.forEach(function (elf,index) {
var notified = false;
if (currTime > parseInt(elf[1])){
GM_notification(elf[0]+ '的将灵可以出征了',"将灵出征提醒");
notified = true;
}
if (currTime > parseInt(elf[2])){
GM_notification(elf[0]+ '的将灵可以领取聚宝盆了',"将灵聚宝盆提醒");
notified = true;
}
if (notified === false){
leftReminder.push(elf);
}
});
GM.setValue("elfReminder",JSON.stringify(leftReminder));
}
}
});
};