js
window.stop = false
let messageShow = false
function autoCheck (force) {
console.error('autoCheck run.');
if (!force && window.stop === true) return ''
// Notification.requestPermission( function(status) {
// console.log(status); // 仅当值为 "granted" 时显示通知
// var n = new Notification("title", {body: "notification body"}); // 显示通知
// });
// 5天后(留五天练车)
let day = new Date().getDate() + 5
let list = document.querySelectorAll('.date-available')
// if (list.length && list[0].getAttribute('aria-label').includes(' August ')) {
// autoTask()
// return ''
// }
for (let i = list.length - 1; i > -1; i--) {
let it = list[i]
// Sunday July 02, 2023
let dt = it.getAttribute('aria-label');
//if (!dt.includes(' August ')) return ''
let mth = dt.includes(' August ') ? 8 : dt.includes(' September ') ? 9 : 0;
let dy = parseInt(dt.split(' August ')[1].split(',')[0], 10)
if ((mth === 8 && dy >= day && dy < 21) || (mth === 9 && dy < 17)) {
console.log(dt)
let arr = [99]
if (!arr.includes(dy)) {
// messageShow = true
new Notification('考试预定', {body: '【' +dt+ '】有'+(dy - day + 5)+'天后的考试可约'}); // 显示通知
}
break
}
}
}
window.setInterval(autoCheck, 6000);
function autoTask (force) {
if (!force && window.stop === true) return ''
let pre = document.querySelector('button[aria-labelledby="previous-label"]')
let nxt = document.querySelector('button[aria-labelledby="next-label"]')
if (pre.disabled) nxt.click()
else pre.click()
}
window.setInterval(autoTask, 17000);
;(function(){
let elem = document.createElement('button')
elem.id = 'btnStop'
document.body.appendChild(elem)
elem.style.position = 'fixed'
elem.style.top = '50px'
elem.style.left = '50px'
elem.style.padding = '30px'
elem.style.zIndex = '100000'
elem.innerText = window.stop ? 'Start' : 'Stop'
elem.onclick = () => { window.stop = !window.stop; document.querySelector('#btnStop').innerText = window.stop ? 'Start' : 'Stop' }
}())