DMHY with WebTor.io

Add WebTor.io links to DMHY

  1. // ==UserScript==
  2. // @name DMHY with WebTor.io
  3. // @namespace https://github.com/gslin/dmhy-webtor-userscript
  4. // @version 0.20200515.1
  5. // @description Add WebTor.io links to DMHY
  6. // @author Gea-Suan Lin <gslin@gslin.com>
  7. // @match https://share.dmhy.org/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. for (let arrow of document.querySelectorAll('a.download-arrow.arrow-magnet')) {
  16. let magneturi = arrow.getAttribute('href');
  17. let magneturi_cleaned = magneturi.substring(0, 2048);
  18.  
  19. let webtor_url = 'https://webtor.io/show?&pwd=%2F&magnet=' + encodeURIComponent(magneturi_cleaned) + '&mode=default'
  20.  
  21. let el = document.createElement('a');
  22. el.classList.add('download-arrow');
  23. el.classList.add('arrow-magnet');
  24. el.setAttribute('href', webtor_url);
  25. el.setAttribute('target', '_blank');
  26.  
  27. arrow.parentElement.appendChild(el);
  28. }
  29. })();