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

  1. // ==UserScript==
  2. // @name Override throttling on pornolab.net
  3. // @namespace Violentmonkey Scripts
  4. // @match *://pornolab.net/*
  5. // @grant none
  6. // @version 1.0
  7. // @author -
  8. // @description Try to reload the page after a random delay in case you get throttled. 2021-09-12 15:02:27
  9. // ==/UserScript==
  10.  
  11.  
  12. // check if this is an error page due to throttling, and if so, refresh it after a random amount of time.
  13. fixed_refresh_delay = 30 // this many seconds to wait at least
  14. max_additional_delay = 30 // this many seconds to wait at least, on top of the fixed delay
  15.  
  16. // no jQuery loaded in the error page, so we have to do things in pure JS
  17. function waitForElm(selector) {
  18. return new Promise(resolve => {
  19. if (document.querySelector(selector)) {
  20. return resolve(document.querySelector(selector))
  21. }
  22.  
  23. const observer = new MutationObserver(mutations => {
  24. if (document.querySelector(selector)) {
  25. resolve(document.querySelector(selector))
  26. observer.disconnect()
  27. }
  28. })
  29.  
  30. observer.observe(document.body, {
  31. childList: true,
  32. subtree: true
  33. })
  34. })
  35. }
  36.  
  37. waitForElm("head > title").then(function(titleElm) {
  38. if (titleElm.textContent == "404 - Service unavailable") {
  39. 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
  40. setTimeout(function(){
  41. window.location.reload(true)
  42. }, delay)
  43. }
  44. })