Custom aliyundrive

阿里云直链导出

当前为 2022-01-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Custom aliyundrive
  3. // @namespace https://github.com/invobzvr
  4. // @version 0.1
  5. // @description 阿里云直链导出
  6. // @author invobzvr
  7. // @match *://www.aliyundrive.com/drive/*
  8. // @grant GM_addStyle
  9. // @homepageURL https://github.com/invobzvr/invotoys.js/tree/main/aliyundrive
  10. // @supportURL https://github.com/invobzvr/invotoys.js/issues
  11. // @license GPL-3.0
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. const that = {
  16. init: async function () {
  17. XMLHttpRequest.prototype.open = that.HOOK.XHR_OPEN;
  18. await new Promise(resolve => {
  19. let root = document.querySelector('#root'),
  20. iid = setInterval(() => root._reactRootContainer && (clearInterval(iid), resolve()), 100);
  21. });
  22. let menu = document.querySelector('ul[class^=nav-menu]'),
  23. btn = menu.firstChild.cloneNode(true);
  24. btn.className = menu.lastChild.className;
  25. btn.lastChild.innerText = 'Export';
  26. btn.addEventListener('click', that.click);
  27. menu.insertAdjacentHTML('beforeend', `<hr>${document.querySelector('[class^=divider]').outerHTML}<hr>`);
  28. menu.insertAdjacentElement('beforeend', btn);
  29. GM_addStyle(`.export-main {
  30. background: #fff;
  31. border-radius: 20px;
  32. box-shadow: 0 0px 20px #0002;
  33. height: 80%;
  34. left: 50%;
  35. overflow: auto;
  36. padding: 20px;
  37. position: fixed;
  38. top: 50%;
  39. transform: translate(-50%, -50%);
  40. width: 80%;
  41. z-index: 999999;
  42. }
  43. .export-main a {
  44. display: block;
  45. `);
  46. },
  47. export: function () {
  48. that.main = document.createElement('div');
  49. that.main.className = 'export-main';
  50. that.main.innerHTML = that.data.filter(ii => ii.type === 'file').map(ii => `<a href="${ii.download_url}" download>${ii.name}</a>`).join('');
  51. that.main.addEventListener('mousedown', evt => evt.stopPropagation());
  52. document.body.append(that.main);
  53. },
  54. click: function () {
  55. if (that.main) {
  56. that.main = that.main.remove();
  57. } else {
  58. that.export();
  59. }
  60. },
  61. ORI: {
  62. XHR_OPEN: XMLHttpRequest.prototype.open,
  63. },
  64. HOOK: {
  65. XHR_OPEN: function () {
  66. if (arguments[1].endsWith('/file/list')) {
  67. this.addEventListener('readystatechange', () => {
  68. if (this.readyState === 4) {
  69. that.data = JSON.parse(this.responseText).items;
  70. }
  71. });
  72. }
  73. return that.ORI.XHR_OPEN.apply(this, arguments);
  74. },
  75. },
  76. };
  77.  
  78. that.init();
  79. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址