Override throttling on pornolab.net

Try to reload the page after a random delay in case you get throttled. 2021-09-12 15:02:27

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Override throttling on pornolab.net
// @namespace   Violentmonkey Scripts
// @match       *://pornolab.net/*
// @grant       none
// @version     1.0
// @author      -
// @description Try to reload the page after a random delay in case you get throttled. 2021-09-12 15:02:27
// ==/UserScript==


// check if this is an error page due to throttling, and if so, refresh it after a random amount of time.
fixed_refresh_delay = 30 // this many seconds to wait at least
max_additional_delay = 30 // this many seconds to wait at least, on top of the fixed delay

// no jQuery loaded in the error page, so we have to do things in pure JS
function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector))
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                resolve(document.querySelector(selector))
                observer.disconnect()
            }
        })

        observer.observe(document.body, {
            childList: true,
            subtree: true
        })
    })
}

waitForElm("head > title").then(function(titleElm) {
  if (titleElm.textContent == "404 - Service unavailable") {
    delay = fixed_refresh_delay + Math.floor(Math.random() * (max_additional_delay + 1)) // the 1 is to make sure the max delay can be reached after the floor() function is done
    setTimeout(function(){
      window.location.reload(true)
    }, delay)
  }
})