Auto Refresher

Automatically refresh websites with a config!

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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 = {
    ".*://www.google.com/": 5000, // This will refresh google.com every 5000 ms (5s)
}


// —————————————————————————————— 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)]);
}