ZJU Tronclass Downloader

Download Tronclass Courseware

当前为 2020-04-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ZJU Tronclass Downloader
  3. // @namespace ncj.wiki
  4. // @version 2.0.2
  5. // @license MIT
  6. // @description Download Tronclass Courseware
  7. // @author NCJ
  8. // @match *://courses.zju.edu.cn/course/*
  9. // @grant none
  10. // @require https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js
  11. // ==/UserScript==
  12.  
  13. $(document).bind('DOMSubtreeModified', function() {
  14. if ($('#Tronclass_Downloader').length == 0 && $('#file-previewer-with-note > div > div > div.header.clearfix').length) {
  15. $('#file-previewer-with-note > div > div > div.header.clearfix').append('<input type="button" value="Download" id="Tronclass_Downloader">')
  16. $("#Tronclass_Downloader").css("position", "relative").css("left", 10);
  17. $('#Tronclass_Downloader').click(function(){
  18. window.open(decodeURIComponent(document.getElementById('pdf-viewer').src.split("?file=")[1]));
  19. });
  20. }
  21.  
  22. if ($('#Tronclass_Downloader_video').length == 0 && $('video').length && $('video')[0].children.length == 3 && $('video')[0].children[0].getAttribute('src').indexOf('/api') == 0) {
  23. var v=$('video')[0];
  24. for (var i of v.children) {
  25. console.log(i.getAttribute('src'));
  26. $(v.parentNode.parentNode).prepend(`<a href="${i.getAttribute('src')}" id="Tronclass_Downloader_video">\t${i.getAttribute('label')}\t</a>`);
  27. }
  28. }
  29. });