commit 11529b1da813c5b8e308cab90ead6c2afe27ec4c Author: einisto <79069176+einisto@users.noreply.github.com> Date: Tue Oct 25 20:39:14 2022 +0300 initial commit diff --git a/download/ylilauta-download-media.js b/download/ylilauta-download-media.js new file mode 100644 index 0000000..746bece --- /dev/null +++ b/download/ylilauta-download-media.js @@ -0,0 +1,42 @@ +// ==UserScript== +// @name Download media - ylilauta.org +// @namespace Violentmonkey Scripts +// @match *://ylilauta.org/* +// @version 1.0 +// ==/UserScript== + + +function download(url) { + 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() + }) +} + + +function init() { + 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) + } +} + + +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) + diff --git a/visual/4chan-expand-images.js b/visual/4chan-expand-images.js new file mode 100644 index 0000000..86142ef --- /dev/null +++ b/visual/4chan-expand-images.js @@ -0,0 +1,28 @@ +// ==UserScript== +// @name Expand all images - 4chan.org +// @namespace Violentmonkey Scripts +// @match *://boards.4channel.org/* +// @match *://boards.4chan.org/* +// @version 1.0 +// ==/UserScript== + + +window.toggle_images = function () { + 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]) + } + } +} + + +const parent_element = document.getElementsByClassName("navLinks desktop")[0] +parent_element.innerHTML += " [Toggle]" + diff --git a/visual/4chan-hide-topics.js b/visual/4chan-hide-topics.js new file mode 100644 index 0000000..d152699 --- /dev/null +++ b/visual/4chan-hide-topics.js @@ -0,0 +1,23 @@ +// ==UserScript== +// @name Hide topics from catalog - 4chan.org +// @namespace Violentmonkey Scripts +// @match *://boards.4channel.org/*/catalog +// @version 1.0 +// ==/UserScript== + + +window.addEventListener("load", function () { + const topics = [] // e.g. ["sdg", "dmp"] + const data = document.getElementsByClassName("teaser") + + for (let i = 0; i < data.length; ++i) { + let inner_txt = data[i].innerText + for (let j = 0; j < topics.length; ++j) { + let topic_str = "/" + topics[j] + "/" + if (inner_txt.includes(topic_str)) { + data[i].offsetParent.style.display = "none" + } + } + } +}) + diff --git a/visual/ylilauta-expand-images.js b/visual/ylilauta-expand-images.js new file mode 100644 index 0000000..4a2d944 --- /dev/null +++ b/visual/ylilauta-expand-images.js @@ -0,0 +1,29 @@ +// ==UserScript== +// @name Expand all images - ylilauta.org +// @namespace Violentmonkey Scripts +// @match *://ylilauta.org/* +// @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) { + media_jpg[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) +