// ==UserScript== // @name Redirect Images on Archived.moe // @namespace http://tampermonkey.net/ // @version 1.0 // @description Redirect images from archived.moe to warosu.org with dynamic URLs // @icon https://s.4cdn.org/image/favicon-ws.ico // @author Anon // @match https://archived.moe/*/thread/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Get the current URL var currentUrl = window.location.href; // Define a regular expression pattern to capture the number sequence var regexPattern = /https:\/\/archived\.moe\/(\w+)\/thread\/(\d+)/; var match = currentUrl.match(regexPattern); if (match) { // Extract the board name and number sequence from the URL var boardName = match[1]; var numberSequence = match[2]; // Pad the number sequence with leading zeros if needed while (numberSequence.length < 4) { numberSequence = '0' + numberSequence; } // Find all anchor elements with class 'thread_image_link' and update their href attributes var imageLinks = document.querySelectorAll('a.thread_image_link'); imageLinks.forEach(function(link) { var href = link.getAttribute('href'); // Extract the last part of the href (the filename) var filename = href.substring(href.lastIndexOf('/') + 1); // Construct the new image URL using both sequences var newImageUrl = "https://warosu.org/data/" + boardName + "/img/0" + numberSequence.substr(0, 3) + "/" + numberSequence.substr(3, 2) + "/" + filename; // Update the href attribute with the new URL link.setAttribute('href', newImageUrl); }); } })();