Expose video url classroom

expose video url classroom

目前为 2024-09-26 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Expose video url classroom
  3. // @namespace https://gf.qytechs.cn/users/821661
  4. // @match https://drive.google.com/file/d/*/view
  5. // @grant none
  6. // @run-at document-start
  7. // @version 1.0
  8. // @author hdyzen
  9. // @description expose video url classroom
  10. // @license GPL-3.0
  11. // ==/UserScript==
  12. 'use strict';
  13.  
  14. const dButton = document.createElement('a');
  15. dButton.innerHTML = `<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="36px" height="36px"><g stroke-width="1" fill-rule="evenodd"><g fill="#fff" transform="translate(85.333333, 64.000000)"><path d="M128,63.999444 L128,106.666444 L42.6666667,106.666667 L42.6666667,320 L256,320 L256,234.666444 L298.666,234.666444 L298.666667,362.666667 L4.26325641e-14,362.666667 L4.26325641e-14,64 L128,63.999444 Z M362.666667,1.42108547e-14 L362.666667,170.666667 L320,170.666667 L320,72.835 L143.084945,249.751611 L112.915055,219.581722 L289.83,42.666 L192,42.6666667 L192,1.42108547e-14 L362.666667,1.42108547e-14 Z" class=""></path></g></g></svg>`;
  16. dButton.target = '_blank';
  17. dButton.style = 'position: fixed; bottom: 10px; right: 10px; z-index: 999999;';
  18.  
  19. const originalXHR = XMLHttpRequest.prototype.open;
  20.  
  21. XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
  22. if (url.includes('get_video_info')) {
  23. this.addEventListener('readystatechange', function (e) {
  24. if (this.readyState === 4) {
  25. try {
  26. const parsedParams = new URLSearchParams(e.target.responseText);
  27. const urls = parsedParams
  28. .get('fmt_stream_map')
  29. .split(',')
  30. .map(url => url.split('|')?.[1]);
  31.  
  32. console.log(urls);
  33.  
  34. dButton.href = urls.at(-1);
  35. document.documentElement.appendChild(dButton);
  36. } catch (error) {
  37. console.error('Erro ao pegar source do video:', error);
  38. }
  39. }
  40. });
  41. }
  42. return originalXHR.apply(this, arguments);
  43. };

QingJ © 2025

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