Advertisement
Chronos_Ouroboros

Redirect Userscripts.org to Userscripts-MIRROR.org

May 30th, 2015
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Redirect Userscripts.org to Userscripts-MIRROR.org
  3. // @namespace uso2usom
  4. // @description On any web page it will check if the clicked links goes to userscripts.org. If so, the link will be rewritten to point to userscripts-mirror.org
  5. // @include http://*.*
  6. // @include https://*.*
  7. // @exclude http://userscripts.org/*
  8. // @exclude https://userscripts.org/*
  9. // @exclude http://userscripts.org:8080/*
  10. // @exclude https://userscripts.org:8080/*
  11. // @version 1
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. // 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.
  16.  
  17. document.body.addEventListener('click', function(e){
  18. var targ = e.target || e.srcElement;
  19. if ( targ && targ.href && targ.href.match('https?:\/\/userscripts.org') ) {
  20. targ.href = targ.href.replace('://userscripts.org', '://userscripts-mirror.org');
  21. }
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement