Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ax = document.createElement('script');
- ax.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js');
- document.body.appendChild(ax);
- const getDownlodsTargets = (type) => {
- let title = document.querySelector('b[class="pull-left"]').
- innerText.replace(/\n/g, '').trim();
- if (type == 'pdf') {
- let pdf = document.querySelector('[class="col-md-2 padding0 col-xs-12"]').href;
- buildBottom(pdf, title, 'pdf');
- } else {
- let video = document.querySelector('.jw-video').src;
- buildBottom(video, title, 'mp4');
- }
- }
- let buildBottom = (url, name, ext) => {
- axios({
- url: url,
- method: 'GET',
- responseType: 'blob',
- headers: {"Access-Control-Allow-Origin": "*"},
- }).then((response) => {
- const url = window.URL.createObjectURL(new Blob([response.data]));
- const link = document.createElement('a');
- link.href = url;
- link.setAttribute('download', `${name}.${ext}`); //or any other extension
- document.body.appendChild(link);
- link.click();
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment