-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoClickLike.user.js
46 lines (43 loc) · 1.58 KB
/
AutoClickLike.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
// ==UserScript==
// @id zunsthy-auto-click-like-qzone
// @name Auto Click Like (user.qzone.qq.com)
// @icon https://user.qzone.qq.com/favicon.ico
// @category utils
// @version 1.0.1
// @updateURL https://raw.githubusercontent.com/zunsthy/userscripts/master/AutoClickLike.meta.js
// @downloadURL https://raw.githubusercontent.com/zunsthy/userscripts/master/AutoClickLike.user.js
// @author ZunSThy <zunsthy@gmail.com>
// @description auto click like button when browse qzone infocenter
// @namespace https://github.com/zunsthy
// @match https://user.qzone.qq.com/*/infocenter
// @include https://user.qzone.qq.com/*/infocenter
// @grant none
// ==/UserScript==
setTimeout(() => {
let off = false;
const unlikes = [];
const checkLikeStatus = el => el.parentNode.classList.contains('item-on');
const random = n => (Math.floor(Math.random() * n * 2) - n);
const createInterval = (fn, interval, detal) => {
const handle = (time) => {
if (off) return;
fn();
setTimeout(handle, time, Math.max(time + random(detal), 100));
};
handle(interval);
};
const collectUnlike = () => {
[...document.querySelectorAll('a:not(.item-on) > i.fui-icon.icon-op-praise')].forEach((el) => {
unlikes.push(el);
});
};
const autoLike = () => {
const icon = unlikes.shift();
if (icon && icon.parentNode && !icon.parentNode.classList.contains('.item-on')) icon.click();
};
createInterval(collectUnlike, 8e3, 200);
createInterval(autoLike, 2e3, 200);
setTimeout(() => {
off = true;
}, 1800e3);
}, 10e3);