Xunlei KuaiChuan Checked Links Text

在新标签页显示迅雷快传中已勾选链接文本

当前为 2014-05-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Xunlei KuaiChuan Checked Links Text
  3. // @namespace qixinglu.com
  4. // @description 在新标签页显示迅雷快传中已勾选链接文本
  5. // @grant none
  6. // @include http://kuai.xunlei.com/d/*
  7. // @version 0.0.1.20140517140353
  8. // ==/UserScript==
  9.  
  10. var addStyle = function(cssText) {
  11. var head = document.querySelector('head');
  12. var style = document.createElement('style');
  13. style.setAttribute('type', 'text/css');
  14. style.textContent = cssText;
  15. head.appendChild(style);
  16. };
  17.  
  18. var replaceButton = function() {
  19. // 复制按钮,避免处理点击事件而弹出下载迅雷提示
  20. var orignalButton = document.querySelector('.general_btn');
  21. var newButton = orignalButton.cloneNode();
  22.  
  23. newButton.addEventListener('click', function() {
  24. var rows = document.querySelectorAll('.file_src li');
  25. var i, row;
  26. var links = [];
  27. for (i = 0; i < rows.length; i += 1) {
  28. row = rows[i];
  29. if (row.querySelector('input.file_chk').checked) {
  30. links.push(row.querySelector('a.file_name').href);
  31. }
  32. }
  33. var text = 'data:text/plain,' + encodeURIComponent(links.join('\n'));
  34. window.open(text);
  35. });
  36.  
  37. orignalButton.parentNode.replaceChild(newButton, orignalButton);
  38. };
  39.  
  40. // 需要用到这个脚本都不需要显示「高速下载」按钮,隐藏掉。
  41. var fileCSS = 'a.high_btn, .adb_txt { display: none; }';
  42.  
  43. // 干掉「离线下载」按钮的菜单
  44. document.querySelector('.oper_list').remove();
  45.  
  46. addStyle(fileCSS);
  47. replaceButton();