proper formatting & fixed syntax

This commit is contained in:
17ms 2022-12-09 03:42:45 +02:00
parent 7c1f2d9d75
commit 5bbde86d50
4 changed files with 46 additions and 56 deletions

View File

@ -5,13 +5,12 @@
// @version 1.0
// ==/UserScript==
function download(url) {
fetch(url, {
mode: "no-cors",
mode: "no-cors"
})
.then(response => response.blob())
.then(blob => {
.then((response) => response.blob())
.then((blob) => {
let blob_url = window.URL.createObjectURL(blob)
let a = document.createElement("a")
a.download = url.split("/")[5]
@ -22,21 +21,20 @@ function download(url) {
})
}
function init() {
const links = Array.from(document.getElementsByClassName("jpg")).concat(Array.from(document.getElementsByClassName("png")))
const links = Array.from(document.getElementsByClassName("jpg")).concat(
Array.from(document.getElementsByClassName("png"))
)
for (let i = 0 i < links.length ++i) {
for (let i = 0; i < links.length; ++i) {
let url = links[i].href
download(url)
}
}
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)

View File

@ -6,7 +6,6 @@
// @version 1.0
// ==/UserScript==
window.toggle_images = function () {
const data = document.getElementsByClassName("fileThumb")
@ -22,7 +21,5 @@ window.toggle_images = function () {
}
}
const parent_element = document.getElementsByClassName("navLinks desktop")[0]
parent_element.innerHTML += " [<a href='javascript:toggle_images()'>Toggle</a>]"

View File

@ -6,7 +6,6 @@
// @version 1.0
// ==/UserScript==
window.addEventListener("load", function () {
const keywords = [] // e.g. ["/sdg/", "luke smith"]
const data = document.getElementsByClassName("teaser")
@ -20,4 +19,3 @@ window.addEventListener("load", function () {
}
}
})

View File

@ -5,25 +5,22 @@
// @version 1.0
// ==/UserScript==
function toggle_images() {
const media_jpg = document.querySelectorAll("a.jpg")
const media_png = document.querySelectorAll("a.png")
for (let i = 0 i < media_jpg.length ++i) {
for (let i = 0; i < media_jpg.length; ++i) {
media_jpg[i].click()
}
for (let i = 0 i < media_png.length ++i) {
for (let i = 0; i < media_png.length; ++i) {
media_png[i].click()
}
}
const activate_link = document.createElement("button")
const parent_element = document.getElementById("navbar")
activate_link.innerText = "Toggle"
activate_link.style.fontSize = "9px"
activate_link.onclick = () => toggle_images()
parent_element.append(activate_link)