Reload on error message

Reload the page on an error message you set yourself

  1. // ==UserScript==
  2. // @name Reload on error message
  3. // @namespace http://userscripts.org/users/23652
  4. // @description Reload the page on an error message you set yourself
  5. // @version 0.5
  6. // @copyright JoeSimmons, Nickel
  7. // @grant none
  8. // @include *
  9. // ==/UserScript==
  10.  
  11. // Add your errors here to the pattern ///////////////
  12. var errors = [];
  13. errors[0] = /Too many connections. Please try again later./i;
  14. errors[1] = /Mysql error, could not connectToo many connections/i;
  15. errors[2] = /max_user_connections/i;
  16. errors[3] = /502 Bad Gateway/i;
  17. errors[4] = /504 Gateway Time-out/i;
  18. errors[5] = /Something broke/i;
  19. errors[6] = /Imgur is over capacity!/i;
  20. errors[7] = /The database timed out running your query./i;
  21. errors[8] = /we took too long to make this page for you/i;
  22. //////////////////////////////////////////////////////
  23.  
  24. function check() {
  25. for(var i=0; i<errors.length; i++) {
  26. if( errors[i].test(document.body.textContent) ){
  27. window.location.reload();
  28. }
  29. }
  30.  
  31. }
  32.  
  33. setTimeout(check, 250);