Skip to content

Instantly share code, notes, and snippets.

@Delivator
Last active September 8, 2020 20:37
Show Gist options
  • Save Delivator/ef9dd5bf16af96ab1438c72bebc1adbc to your computer and use it in GitHub Desktop.
Save Delivator/ef9dd5bf16af96ab1438c72bebc1adbc to your computer and use it in GitHub Desktop.
User script which creates a SkyGallery album from a 4chan tread
// ==UserScript==
// @name 4chan to SkyGallery
// @namespace https://delivator.me
// @version 0.1
// @description User script which creates a SkyGallery album from a 4chan tread
// @author Delivator
// @match https://boards.4chan.org/*/thread/*
// @match https://boards.4channel.org/*/thread/*
// @grant none
// ==/UserScript==
(function () {
"use strict";
const titleRegex = /^\/[a-zA-Z0-9]{1,5}\/ - (.*) - .*\/.* - 4chan$/;
let albumTitle = "Untitled Album";
let files = []
if (titleRegex.test(document.title))
albumTitle = document.title.match(titleRegex)[1];
console.log(`Album Title: ${albumTitle}`);
document.querySelectorAll(".fileText").forEach(async (element) => {
const linkElement = element.querySelector("a");
console.log(`${linkElement.href}: ${linkElement.innerText}`);
try {
let file = await fetch(linkElement.href).blob();
} catch (error) {
console.error(error);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment