Redirect Userscripts.org to Userscripts-MIRROR.org

On any web page it will check if the clicked links goes to userscripts.org or userscripts.org:8080. If so, the link will be rewritten to point to userscripts-mirror.org.

当前为 2014-08-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Redirect Userscripts.org to Userscripts-MIRROR.org
  3. // @description On any web page it will check if the clicked links goes to userscripts.org or userscripts.org:8080. If so, the link will be rewritten to point to userscripts-mirror.org.
  4. // @include http://*.*
  5. // @include https://*.*
  6. // @exclude http://userscripts-mirror.org/*
  7. // @exclude https://userscripts-mirror.org/*
  8. // @version 0.1
  9. // @grant none
  10. // @namespace https://greasyfork.org/users/4051
  11. // ==/UserScript==
  12.  
  13. // This is a slightly brute force solution, but there is no other way to do it using only a userscript. A full-fledged addon may be created soon.
  14.  
  15. document.body.addEventListener('click', function(e){
  16. var targ = e.target || e.srcElement;
  17. if ( targ && targ.href && targ.href.match('https?:\/\/userscripts.org\/') ) {
  18. targ.href = targ.href.replace('://userscripts.org/', '://userscripts-mirror.org/');
  19. }
  20. if ( targ && targ.href && targ.href.match('https?:\/\/userscripts.org:8080') ) {
  21. targ.href = targ.href.replace('://userscripts.org:8080', '://userscripts-mirror.org');
  22. }
  23. });