Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xhtmlrequest:
- 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 }) {
- let req = new XMLHttpRequest();
- req.open( "GET", url, true );
- req.setRequestHeader("origin", url);
- req.responseType = "blob";
- req.send (null);
- req.onload = function(resp){
- var img = document.createElement('img');
- img.src = window.URL.createObjectURL(req.response);
- document.body.appendChild(img);
- save(img.src,name)
- }
- }
- document.addEventListener('contextmenu', event => {
- const img = event.currentTarget.querySelector('a') || {};
- const src = event.target.href;
- 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 });
- }
- });
- fetch request :
- 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(function(resp){
- var img = document.createElement('img');
- img.src = response.json();
- document.body.appendChild(img);
- save(img.src,name)
- })}
- document.addEventListener('contextmenu', event => {
- const img = event.currentTarget.querySelector('a') || {};
- const src = event.target.href;
- 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