Redirect torcache.net to itorrents.org

Change torcache.net links on torrent websites to itorrents.org links

当前为 2016-08-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Redirect torcache.net to itorrents.org
  3. // @namespace http://www.dieterholvoet.com
  4. // @version 1.0
  5. // @description Change torcache.net links on torrent websites to itorrents.org links
  6. // @author Dieter Holvoet
  7. // @match https://torrentproject.se/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. switch(window.location.hostname) {
  14. case "torrentproject.se":
  15. torrentproject();
  16. break;
  17. }
  18. })();
  19.  
  20. function torrentproject() {
  21. var urls = document.querySelectorAll(".usite a");
  22. for(var i = 0; i < urls.length; i++) {
  23. var text = urls[i].innerHTML,
  24. href = urls[i].getAttribute("href");
  25. if(text.indexOf("torcache.net") !== -1) {
  26. console.log(text, href);
  27. urls[i].innerHTML = text.replace("torcache.net", "itorrents.org");
  28. urls[i].setAttribute("href", href.replace("torcache.net", "itorrents.org"));
  29. }
  30. }
  31. }