Egger0

dllllll

Jan 23rd, 2021 (edited)
870
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ax = document.createElement('script');
  2. ax.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js');
  3.  
  4. document.body.appendChild(ax);
  5.  
  6. const getDownlodsTargets = (type) => {
  7.     let title = document.querySelector('b[class="pull-left"]').
  8.         innerText.replace(/\n/g, '').trim();
  9.     if (type == 'pdf') {
  10.         let pdf = document.querySelector('[class="col-md-2 padding0 col-xs-12"]').href;
  11.         buildBottom(pdf, title, 'pdf');
  12.     } else {
  13.         let video = document.querySelector('.jw-video').src;
  14.         buildBottom(video, title, 'mp4');
  15.     }
  16. }
  17.  
  18. let buildBottom = (url, name, ext) => {
  19.     axios({
  20.         url: url,
  21.         method: 'GET',
  22.         responseType: 'blob',
  23.         headers: {"Access-Control-Allow-Origin": "*"},
  24.     }).then((response) => {
  25.         const url = window.URL.createObjectURL(new Blob([response.data]));
  26.         const link = document.createElement('a');
  27.         link.href = url;
  28.         link.setAttribute('download', `${name}.${ext}`); //or any other extension
  29.         document.body.appendChild(link);
  30.         link.click();
  31.     });
  32. }
Advertisement
Add Comment
Please, Sign In to add comment