Skip to content

Commit 820af93

Browse files
committedSep 13, 2021
Add gmhp-bank.user.js
1 parent 033bbdf commit 820af93

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
 

‎autoclick-gmhp-bank/gmhp-bank.user.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// ==UserScript==
2+
// @namespace https://github.com/KhanhhNe
3+
// @name GMHP-Bonus
4+
// @description Click bonus 6h, 20h, 24h tự động của gmhp-bank.xyz
5+
// @icon https://www.google.com/s2/favicons?domain=gmhp-bank.xyz
6+
// @copyright 2021, KhanhhNe (https://github.com/KhanhhNe)
7+
// @license CC-BY-SA-3.0; http://creativecommons.org/licenses/by-sa/3.0/
8+
// @license MIT
9+
// @version 1.0.0
10+
// @include https://gmhp-bank.xyz/bonus_gift*
11+
// @grant none
12+
// ==/UserScript==
13+
14+
// ==OpenUserJS==
15+
// @author KhanhhNe
16+
// ==/OpenUserJS==
17+
18+
19+
/*jshint esversion: 9 */
20+
/*jshint asi: true */
21+
22+
23+
/**
24+
* Lấy bonus từ URL /bonus_gift_<number>/
25+
* @returns Số thứ tự bonus hiện tại
26+
*/
27+
function currentBonus() {
28+
return parseInt(location.href.match(/bonus_gift_(\d)/)[1])
29+
}
30+
31+
32+
/**
33+
* Lấy số thứ tự bous tiếp theo của currentBonus() (1 -> 2 -> 3 -> 1 -> ...)
34+
* @returns Số thứ tự bonus tiếp theo
35+
*/
36+
function nextBonus() {
37+
return currentBonus() % 3 + 1
38+
}
39+
40+
41+
/**
42+
* Chuyển hướng sang URL của bonus tiếp theo
43+
*/
44+
function gotoNextBonus() {
45+
location.replace(`https://gmhp-bank.xyz/bonus_gift_${nextBonus()}/`)
46+
}
47+
48+
49+
(function main() {
50+
// Chuyển sang bonus tiếp theo nếu bonus hiện tại chưa hết thời gian chờ
51+
if (document.querySelector('#timer_word_id')) {
52+
console.log(`Bonus ${currentBonus()} đã nhận từ trước. Đang chuyển hướng đến bonus tiếp theo...`);
53+
setTimeout(gotoNextBonus, 30000)
54+
return
55+
}
56+
57+
// Chạy hàm onclick của banner (nhưng không click để tránh bị redirect, mở tab mới,...)
58+
const banner = document.querySelector(`.bonus_gift_${currentBonus()}_banner_2 a`)
59+
if (banner !== null) {
60+
console.log(`Đã click banner của bonus ${currentBonus()}!`);
61+
eval(banner.getAttribute('onclick'))
62+
}
63+
64+
// Nhấn 'Receive'
65+
setInterval(() => document.querySelector(`#bonus_gift_${currentBonus()}_button`).click(), 5000)
66+
console.log(`Đã nhận bonus ${currentBonus()}!`);
67+
})();

0 commit comments

Comments
 (0)