2022-10-25 19:39:14 +02:00
|
|
|
// ==UserScript==
|
2023-02-21 21:47:46 +01:00
|
|
|
// @name y-media-downloader
|
|
|
|
// @description General media downloader
|
2023-02-28 20:05:00 +01:00
|
|
|
// @author 17ms
|
|
|
|
// @license MIT License
|
2022-10-25 19:39:14 +02:00
|
|
|
// @namespace Violentmonkey Scripts
|
|
|
|
// @match *://ylilauta.org/*
|
|
|
|
// @version 1.0
|
|
|
|
// ==/UserScript==
|
|
|
|
|
|
|
|
function download(url) {
|
2023-06-01 16:55:54 +02:00
|
|
|
fetch(url, {
|
|
|
|
mode: "no-cors",
|
2022-10-25 19:39:14 +02:00
|
|
|
})
|
2023-06-01 16:55:54 +02:00
|
|
|
.then((response) => response.blob())
|
|
|
|
.then((blob) => {
|
|
|
|
let blob_url = window.URL.createObjectURL(blob)
|
|
|
|
let a = document.createElement("a")
|
|
|
|
a.download = url.split("/")[5]
|
|
|
|
a.href = blob_url
|
|
|
|
document.body.appendChild(a)
|
|
|
|
a.click()
|
|
|
|
a.remove()
|
|
|
|
})
|
2022-10-25 19:39:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function init() {
|
2023-06-01 16:55:54 +02:00
|
|
|
const links = Array.from(document.getElementsByClassName("jpg")).concat(
|
|
|
|
Array.from(document.getElementsByClassName("png"))
|
|
|
|
)
|
2022-12-09 02:42:45 +01:00
|
|
|
|
2023-06-01 16:55:54 +02:00
|
|
|
for (let i = 0; i < links.length; ++i) {
|
|
|
|
let url = links[i].href
|
|
|
|
download(url)
|
|
|
|
}
|
2022-10-25 19:39:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const activate_link = document.createElement("button")
|
|
|
|
const parent_element = document.getElementById("navbar")
|
|
|
|
activate_link.innerText = "⮶"
|
|
|
|
activate_link.style.fontSize = "30px"
|
|
|
|
activate_link.onclick = () => init()
|
|
|
|
parent_element.append(activate_link)
|