pzy64X

rffe

Oct 29th, 2019
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var videoLink = document.querySelector(".vjs-tech").getAttribute('src');
  2.  
  3.  
  4. var oReq = new XMLHttpRequest();
  5.  
  6. oReq.onload = function (oEvent) {
  7.   var blob = oReq.response;
  8.  
  9.     var url = window.URL.createObjectURL(blob);
  10.  
  11.     var a = document.createElement('a');
  12.     a.style = "display: none";  
  13.     a.href = url;
  14.     a.download = getCourseName()+'.mp4';
  15.     document.body.appendChild(a);
  16.     a.click();
  17.     document.body.removeChild(a);
  18.     window.URL.revokeObjectURL(url);    
  19.  
  20. };
  21.  
  22. oReq.open("GET",videoLink,true );
  23. oReq.responseType = "blob";
  24. oReq.send();
  25.  
  26. function getCourseName()    {
  27.     var listTagNames = document.getElementsByTagName("LI")
  28.   for(var i = 0; i < listTagNames.length; i++) {
  29.     var obj = listTagNames[i].getAttribute("aria-current");
  30.     if (obj == "true") {
  31.    
  32.     var content = listTagNames[i];
  33.     var courseName = content.getElementsByTagName("div")[0].getAttribute("aria-label");
  34.    
  35.    return courseName;
  36.     }
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment