Disable AutoRefresh

Disable AutoRefresh is a user script to override and disable meta refresh html tag on all websites to prevent the automatic refresh or redirection.

当前为 2016-01-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Disable AutoRefresh
  3. // @name:fr Disable AutoRefresh
  4. // @namespace Disable AutoRefresh
  5. // @description Disable AutoRefresh is a user script to override and disable meta refresh html tag on all websites to prevent the automatic refresh or redirection.
  6. // @description:fr Disable AutoRefresh est un user script pour annuler et désactiver le tag html Meta refresh sur tous les sites web et empêcher le rafraîchissement automatique ou la redirection vers une autre page / site web.
  7. // @author SMed79
  8. // @version 1.0
  9. // @encoding utf-8
  10. // @license https://creativecommons.org/licenses/by-nc-sa/4.0/
  11. // @icon http://i.imgur.com/ZJ9mHLO.png
  12. // @twitterURL https://twitter.com/SMed79
  13. // @contactURL http://tinyurl.com/contact-smed79
  14. // @supportURL https://greasyfork.org/fr/scripts/16079-disable-autorefresh/feedback
  15. // @include http://*
  16. // @include https://*
  17. // @grant none
  18. // ==/UserScript==
  19.  
  20. (function() {
  21.  
  22. var allMetas, thisMeta, content, timeout, timeout_ms, url;
  23.  
  24. timeout = -1;
  25. url = 'none';
  26.  
  27. allMetas = document.getElementsByTagName('meta');
  28. for (var i = 0; i < allMetas.length; i++) {
  29. thisMeta = allMetas[i];
  30.  
  31. if (thisMeta.httpEquiv.match(/refresh/i)) {
  32. if (thisMeta.content.match(/[\D]/)) {
  33. content = thisMeta.content.split(';');
  34. timeout = content[0];
  35.  
  36. url = thisMeta.content.match(/url=['"]?([^'"]+)['"]?$/i);
  37. url = RegExp.lastParen;
  38. }
  39. }
  40. }
  41.  
  42. if (timeout >= 0) {
  43. var stopTimer = window.setTimeout("window.stop();", timeout_ms);
  44. window.addEventListener("load", function() {
  45. try {
  46. window.clearTimeout(stopTimer);
  47. } catch (ex) {}
  48. window.stop();
  49. }, true);
  50. }
  51.  
  52. })();