Automatically refresh websites with a config!
当前为
// ==UserScript==
// @name Auto Refresher
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description Automatically refresh websites with a config!
// @author DeltAndy
// @match *://*/*
// @grant none
// ==/UserScript==
// ———————————————————————————————————— Config —————————————————————————————————————————
// The key is the website URL (with RegExp), and the value is the time in milliseconds
const reloadPages = {
".*://meet.google.com/_meet/whoops.*": 5000
}
// —————————————————————————————— Do Not Modify Below ——————————————————————————————————
function regexMatches(arr, regex) {
for (const i of arr) {
var regexp = new RegExp(regex)
if (i.replace(regexp, '') === '') return true
}
return false
}
function arrayMatches(regArr, str) {
for (const i of regArr) {
var regexp = new RegExp(i)
if (str.replace(regexp, '') === '') return true
}
return false
}
function regexIndexOf(regArr, str) {
var i = 0
for (const reg of regArr) {
const regex = new RegExp(reg)
if (str.replace(regex, '') === '') return i
i++
}
return -1
}
var urls = []
for(var key in reloadPages) urls.push(key)
const websiteRegex = new RegExp(reloadPages[window.location.href])
if (arrayMatches(urls, window.location.href)) {
console.log(`Reloading page in ${Object.values(reloadPages)[regexIndexOf(urls, window.location.href)]} ms`)
setTimeout(() => {
window.location = window.location
}, Object.values(reloadPages)[regexIndexOf(urls, window.location.href)]);
}