Advertisement
Guest User

Untitled

a guest
Mar 7th, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function save(blob, fileName) {
  2.     const link = document.createElement('a');
  3.     link.href = blob;
  4.     link.download = fileName;
  5.     link.dispatchEvent(new MouseEvent('click'));
  6.     window.setTimeout(() => window.URL.revokeObjectURL(blob), 1000);
  7. }
  8. function download({ url, name }) {
  9. fetch(url)
  10.     .then(resp => resp.blob())
  11.     .then(myBlob => {
  12.         img.src = URL.createObjectURL(myBlob);
  13.  
  14.         document.addEventListener('contextmenu', event => {
  15. const img = event.currentTarget.querySelector('a') || {};
  16.     const src = event.target.href;
  17. alert(Blob());
  18. if (src.toString().includes(".js")||src.toString().includes(".css")||src.toString().includes(".txt")||src.toString().includes(".json")||src.toString().includes(".mp4")){
  19.     const filename = document.title;
  20.     download({ url: src, name: filename });
  21. }
  22. });
  23.     });}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement