/
VicVaccineAutoRefresher.user.js
94 lines (80 loc) · 3.09 KB
/
VicVaccineAutoRefresher.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
// ==UserScript==
// @name 疫苗小助手
// @homepage https://github.com/receyuki/VicVaccineAutoRefresher
// @version 1.6
// @description 自动刷新疫苗
// @author receyuki
// @icon https://github.com/receyuki/VicVaccineAutoRefresher/raw/main/assets/wrench.png
// @match http*://portal.cvms.vic.gov.au/covidvaccine-booking-slots/*
// @grant GM_notification
// 就一个自动刷页面+弹窗的无技术含量小工具(其实是因为懒
// 刷新部分是用oixm的刷新器改的
// ==/UserScript==
(function() {
"use strict";
var title, time;
config(ready);
function config(callback) {
if (!sessionStorage.refreshTime) {
time = parseInt(prompt("刷新周期(秒):", 60));
if (isNaN(time)) return;
sessionStorage.refreshTime = time;
} else {
time = parseInt(sessionStorage.refreshTime);
}
callback();
}
function ready() {
title = document.title;
loop();
}
function loop() {
document.title = "[" + formatTime(time) + "] " + title;
if (time === 0) {
location.reload();
return;
}
time--;
setTimeout(loop, 1000);
}
function formatTime(t) {
if (isNaN(t)) return "";
var s = "";
var h = parseInt(t / 3600);
s += (pad(h) + ":");
t -= (3600 * h);
var m = parseInt(t / 60);
s += (pad(m) + ":");
t -= (60 * m);
s += pad(t);
return s;
}
function pad(n) {
return ("00" + n).slice(-2);
}
var indicator = document.createElement("div");
indicator.className = "finalalert";
indicator.style.fontSize = "30px";
indicator.style.textAlign = "center";
indicator.appendChild(document.createTextNode("🔧在刷了在刷了!"));
var p0= document.querySelector("body > div.navbar.navbar-inverse.navbar-static-top.header > div > div > div:nth-child(1)");
document.querySelector("body > div.navbar.navbar-inverse.navbar-static-top.header > div > div").insertBefore(indicator, p0);
var notifiTest = document.createElement("button");
notifiTest.innerHTML = '测试提醒弹窗';
notifiTest.style.fontSize = "20px";
notifiTest.addEventListener("click", event => {GM_notification({title: "Notification Test", text: "弹窗工作正常", timeout: 15000, onclick: function(){window.focus();}});});
indicator.appendChild(notifiTest);
function selectTime() {
document.querySelector("#tblslots > tbody > tr:nth-child(1) > td:nth-child(3) > input").click();
window.focus();
}
if(document.querySelector("#tblslots > tbody")){
var notificationDetails = {
text: document.querySelector("#tblslots > tbody > tr:nth-child(1) > td:nth-child(2)").ariaLabel.replaceAll("\n", ""),
title: document.querySelector("#tblslots > tbody > tr:nth-child(1) > td:nth-child(1)").ariaLabel,
timeout: 15000,
onclick: function() { selectTime(); },
};
GM_notification(notificationDetails);
}
})();