-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathwuxia.qq.user.js
127 lines (98 loc) · 2.7 KB
/
wuxia.qq.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// ==UserScript==
// @name wuxia
// @namespace https://github.com/reruin
// @version 0.1
// @license MIT
// @description wuxia
// @author [email protected]
// @grant none
// @include http://wuxia.qq.com/cp/a20180117tdspring/
// @connect *
// @run-at document-start
// ==/UserScript==
function noop() {
return true;
}
(function(){
function addScript(script, pos) {
var el = document.createElement("script");
el.textContent = script;
if (typeof pos == 'object') {
pos.appendChild(el)
} else if (pos == 'head') {
document.getElementsByTagName('head')[0].appendChild(el);
} else {
document.getElementsByTagName('body')[0].appendChild(el);
}
}
var script = function() {
// 0 今日未打卡 1 下一轮打卡 2 今日已经打卡
var status = 0;
var el;
var lastReport;
function logger(t){
console.log("\n %c "+t+" \n","color: #fadfa3; background: #030307; padding:5px 0;");
}
function createDom(span , id , style){
var el = document.createElement(span);
el.id = id;
el.style = style;
document.body.appendChild(el);
return el;
}
function request(url , data){
let fetchData = {
method: 'GET',
credentials: "include",
}
if(data){
fetchData.body = JSON.stringify(data)
}
return new Promise(function(resolve, reject) {
fetch(url, fetchData).then(function(resp) {
resolve(resp.text())
},function(e) {
reject(e)
}).catch(function(e) {
reject(e)
})
})
}
function init(){
el = createDom('div' , '_tips_' , 'position:fixed;height:48px;line-height:48px;box-sizing:border-box;padding:0 20px; width : 100%;background:#ff0000;color:#fff;z-index:9999;bottom:0;left:0;');;
el.innerHTML = '自动打卡中'
process()
}
function action(){
document.querySelector('.btn-log').click()
}
function timeHit(){
var date = new Date()
el.innerHTML = '自动打卡中(上次检查:'+date.toLocaleString()+' )'
var h = date.getHours()
if( h == 8 ){
if(status == 0){
status = 1
}
}else if(h == 0){
status = 0
}
}
function process(){
request(location.href).then(function(resp){
timeHit()
if( status == 1 ){
action()
status = 2
}else{
setTimeout( function(){
process()
} , 30 * 1000 )
}
})
}
var url = location.href , pathname = location.pathname
init()
}
addScript(';(' + script + '());', 'body');
}());