proper formatting & fixed syntax
This commit is contained in:
parent
7c1f2d9d75
commit
5bbde86d50
@ -5,38 +5,36 @@
|
||||
// @version 1.0
|
||||
// ==/UserScript==
|
||||
|
||||
|
||||
function download(url) {
|
||||
fetch(url, {
|
||||
mode: "no-cors",
|
||||
fetch(url, {
|
||||
mode: "no-cors"
|
||||
})
|
||||
.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()
|
||||
})
|
||||
.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()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
let url = links[i].href
|
||||
download(url)
|
||||
}
|
||||
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)
|
||||
|
||||
|
@ -6,23 +6,20 @@
|
||||
// @version 1.0
|
||||
// ==/UserScript==
|
||||
|
||||
|
||||
window.toggle_images = function () {
|
||||
const data = document.getElementsByClassName("fileThumb")
|
||||
const data = document.getElementsByClassName("fileThumb")
|
||||
|
||||
for (let i = 0; i < data.length; ++i) {
|
||||
let img_data = data[i].getElementsByTagName("img")
|
||||
if (img_data[0].className === "fileDeletedRes retina") {
|
||||
continue
|
||||
} else if (img_data.length === 1) {
|
||||
ImageExpansion.expand(img_data[0])
|
||||
} else {
|
||||
ImageExpansion.contract(img_data[1])
|
||||
}
|
||||
for (let i = 0; i < data.length; ++i) {
|
||||
let img_data = data[i].getElementsByTagName("img")
|
||||
if (img_data[0].className === "fileDeletedRes retina") {
|
||||
continue
|
||||
} else if (img_data.length === 1) {
|
||||
ImageExpansion.expand(img_data[0])
|
||||
} else {
|
||||
ImageExpansion.contract(img_data[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const parent_element = document.getElementsByClassName("navLinks desktop")[0]
|
||||
parent_element.innerHTML += " [<a href='javascript:toggle_images()'>Toggle</a>]"
|
||||
|
||||
|
@ -6,18 +6,16 @@
|
||||
// @version 1.0
|
||||
// ==/UserScript==
|
||||
|
||||
|
||||
window.addEventListener("load", function () {
|
||||
const keywords = [] // e.g. ["/sdg/", "luke smith"]
|
||||
const data = document.getElementsByClassName("teaser")
|
||||
const keywords = [] // e.g. ["/sdg/", "luke smith"]
|
||||
const data = document.getElementsByClassName("teaser")
|
||||
|
||||
for (let i = 0; i < data.length; ++i) {
|
||||
let inner_txt = data[i].innerText
|
||||
for (let j = 0; j < keywords.length; ++j) {
|
||||
if (inner_txt.includes(keywords[j])) {
|
||||
data[i].offsetParent.style.display = "none"
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < data.length; ++i) {
|
||||
let inner_txt = data[i].innerText
|
||||
for (let j = 0; j < keywords.length; ++j) {
|
||||
if (inner_txt.includes(keywords[j])) {
|
||||
data[i].offsetParent.style.display = "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -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")
|
||||
const media_jpg = document.querySelectorAll("a.jpg")
|
||||
const media_png = document.querySelectorAll("a.png")
|
||||
|
||||
for (let i = 0 i < media_jpg.length ++i) {
|
||||
media_jpg[i].click()
|
||||
}
|
||||
for (let i = 0; i < media_jpg.length; ++i) {
|
||||
media_jpg[i].click()
|
||||
}
|
||||
|
||||
for (let i = 0 i < media_png.length ++i) {
|
||||
media_png[i].click()
|
||||
}
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user