Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function save(blob, fileName) {
- const link = document.createElement('a');
- link.href = blob;
- link.download = fileName;
- link.dispatchEvent(new MouseEvent('click'));
- window.setTimeout(() => window.URL.revokeObjectURL(blob), 1000);
- }
- function download({ url, name }) {
- fetch(url)
- .then(resp => resp.blob())
- .then(myBlob => {
- img.src = URL.createObjectURL(myBlob);
- document.addEventListener('contextmenu', event => {
- const img = event.currentTarget.querySelector('a') || {};
- const src = event.target.href;
- alert(Blob());
- if (src.toString().includes(".js")||src.toString().includes(".css")||src.toString().includes(".txt")||src.toString().includes(".json")||src.toString().includes(".mp4")){
- const filename = document.title;
- download({ url: src, name: filename });
- }
- });
- });}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement