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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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)
  }
})