Downloads image when you click to "download image" on zerochan.net.
当前为
// ==UserScript==
// @name Directly download image from zerochan.net
// @namespace https://myanimelist.net/profile/kyoyatempest
// @match https://static.zerochan.net/*
// @version 1.1
// @author kyoyacchi
// @description Downloads image when you click to "download image" on zerochan.net.
// @license gpl-3.0
// ==/UserScript==
window.onload = function (){
let isim = window.location.href.split("/")[3] || "zerochan.png"
downloadImage(window.location.href,isim)
let dogrula = window.confirm("Wanna go back to zerochan after downloading image?")
if (dogrula) {
setTimeout(() => {
window.history.back()
}, 10000) //ten secs.
}
}
function downloadImage(url, name){
fetch(url)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = name;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
})
.catch(() => alert('An error occured.'));
}
// https://stackoverflow.com/a/68722398/19276081