Greasy Fork is available in English.

115 Download Helper

115网盘下载帮手,能自动帮忙点普通下载,少点一次鼠标,能够批量复制下载链接

  1. // ==UserScript==
  2. // @name 115 Download Helper
  3. // @authuer ted423
  4. // @description 115网盘下载帮手,能自动帮忙点普通下载,少点一次鼠标,能够批量复制下载链接
  5. // @include http://115.com/?ct=*
  6. // @version 2016.02.20.0
  7. // @grant GM_xmlhttpRequest
  8. // @grant GM_setClipboard
  9. // @run-at document-end
  10. // @license MIT
  11. // @namespace https://greasyfork.org/users/85
  12. // downloadURL https://github.com/ted423/rules-GM-stylish-UC/raw/master/GM/115%20Download%20Helper.user.js
  13. // ==/UserScript==
  14. if(self.document.URL.indexOf('http://115.com/?ct=')!=-1){
  15. var callback = function(records){
  16. records.map(function(record){
  17. if(record.addedNodes[0]){
  18. /*
  19. if(record.addedNodes[0].baseURI.indexOf('http://115.com/?ct=download')!=-1&&record.addedNodes[0].nodeName=='#text'){
  20. var target=self.document.querySelector('.btn-green');
  21. target.removeAttribute('target');
  22. target.click();
  23. }
  24. */
  25. if(record.target.id=='js_operate_box'){
  26. if(!document.querySelector('li[menu="export"]')){
  27. var li = document.createElement('li');
  28. li.innerHTML = '<span>批量复制下载链接</span>';
  29. li.onclick=function(){
  30. var arr=[];
  31. i=0;
  32. [].forEach.call(selected,function(oneSelected){
  33. URL="http://web.api.115.com/files/download?pickcode="+oneSelected.getAttribute('pick_code')+"&_="+(new Date()).valueOf();
  34. console.log(URL);
  35. getDownloadUrl(URL,arr,li,selected.length);
  36. })
  37. }
  38. record.target.firstChild.appendChild(li);
  39. var selected = document.querySelectorAll('li.selected');
  40. }
  41. }
  42. }
  43. })
  44. }
  45.  
  46. var option = {
  47. 'childList': true,
  48. 'subtree': true,
  49. };
  50. function getDownloadUrl(URL,arr,li,length){
  51. GM_xmlhttpRequest({
  52. method:'GET',
  53. url:URL,
  54. headers:{
  55. "Referer":"http://web.api.115.com/bridge_2.0.html?namespace=Core.DataAccess&api=UDataAPI&_t=v5",
  56. "Accept":"*/*",
  57. },
  58. onload:function(response){
  59. //console.log(response.responseText);
  60. geturl=JSON.parse(response.responseText).file_url;
  61. //console.log(geturl);
  62. arr.push(geturl);
  63. i++;
  64. if(i==length){
  65. //console.log(arr.join('\n'));
  66. GM_setClipboard(arr.join('\n'),'text');
  67. li.style.fontWeight='bold';
  68. setTimeout(function(){li.style.fontWeight=''},2000)
  69. }
  70. },
  71. });
  72. }
  73.  
  74. if(self.document.URL.indexOf('http://115.com/?ct=pickcode')!=-1)
  75. {
  76. var click = new MutationObserver(callback);
  77.  
  78. click.observe(document, option);
  79. }
  80. else{
  81. var Firstload = new MutationObserver(callback);
  82. Firstload.observe(document, option);
  83. //console.log(self.document.URL);
  84. }
  85. }