// ==UserScript== // @name 8moe unspoiler // @namespace 8moe unspoiler // @version 1.0 // @description 8moe thumbnail spoiler begone // @author Anonpipi // @match *://8chan.moe/*/res/* // @icon https://www.google.com/s2/favicons?sz=64&domain=8chan.moe // @grant none // @require https://code.jquery.com/jquery-3.7.1.min.js // ==/UserScript== function unspoilerThumbnail(postImage) { if (postImage.src.endsWith('/spoiler.png') || postImage.src.endsWith('custom.spoiler')) { const fileURL = postImage.parentNode.href; if (fileURL === undefined || fileURL.indexOf('/.media/') == -1) return; const spoilerImg = postImage.src; const thumbURL = fileURL.replace('/.media/', '$&t_').replace((/\.(jpg|jpeg|png|gif|webp|webm|mp4)$/), ''); postImage.onerror = () => postImage.src = spoilerImg; postImage.onload = () => { postImage.style.width = `${postImage.naturalWidth}px`; postImage.style.height = `${postImage.naturalHeight}px`; }; postImage.src = thumbURL; $(postImage).css({"box-shadow": "0px 0px 5px #f00"}); } } const observer = new MutationObserver(function(mutationList) { for (var mutation of mutationList.filter((m) => m.target.className === 'divPosts' || m.target.className === 'quoteTooltip')) { for (var child of mutation.addedNodes) { for (var img of $(child).find('.imgLink img')) { unspoilerThumbnail(img) } } } }); (function () { 'use strict'; document.querySelectorAll('.imgLink img').forEach(unspoilerThumbnail); observer.observe(document, {childList: true, subtree: true}); })();