// ==UserScript== // @name Endchan Disable Image Spoilers // @namespace http://localhost/ // @version 1.0 // @description Endchan: disable image spoilers // @author Dobroanon // @match https://endchan.gg/*/* // @match https://endchan.net/*/* // @match https://endchan.org/*/* // @match http://endchan.gg/*/* // @match http://endchan.net/*/* // @match http://endchan.org/*/* // @match http://endchancxfbnrfgauuxlztwlckytq7rgeo5v6pc2zd4nyqo3khfam4ad.onion/*/* // @match http://enxx3byspwsdo446jujc52ucy2pf5urdbhqw3kbsfhlfjwmbpj5smdad.onion/*/* // @match http://kqrtg5wz4qbyjprujkz33gza7r73iw3ainqp1mz5zmu16symcdwy.loki/*/* // @match https://kqrtg5wz4qbyjprujkz33gza7r73iw3ainqp1mz5zmu16symcdwy.loki/*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=endchan.gg // @run-at document-start // @grant none // ==/UserScript== // // modified code from https://endchan.gg/.static/delPost.js // copyleft by /dobrochan/, 2022 for endchan with love // function unspoilPosts() { var input=document.getElementById('DisableSpoilers'); if(input.checked) { jQuery('.uploadCell').each(function(index, imageContainer) { var imagePath = jQuery(imageContainer).find('.imgLink').attr('href'); if(typeof imagePath == "undefined") return; var imagePathWithoutExt = imagePath.substr(0, imagePath.lastIndexOf('.')); var imageFileName = imagePathWithoutExt.substring(imagePathWithoutExt.lastIndexOf("/") + 1); var imagePathDir = imagePathWithoutExt.substring(0, imagePathWithoutExt.lastIndexOf("/") + 1); jQuery(imageContainer).find('.imgLink img[src*=spoiler]') .data('spoiler', jQuery(imageContainer).find('.imgLink img[src*=spoiler]').attr('src')) .attr('src', imagePathDir + 't_' + imageFileName) }) } else { jQuery('.uploadCell').each(function(index, imageContainer) { if(jQuery(imageContainer).find('.imgLink img').data('spoiler')) { jQuery(imageContainer).find('.imgLink img').attr('src', jQuery(imageContainer).find('.imgLink img').data('spoiler')); } }) } var days=365*10; // remember this setting for 10 years setSetting('myDisableSpoilers', input.checked?'true':'false', days); } document.addEventListener("DOMContentLoaded", function(event) { var c=document.querySelector('select[name=switchcolorcontrol]'); var label=document.createElement('label'); label.style.display='inline'; label.id='DisableSpoilersLbl'; // Add new post listener only if we're browsing a thread // if(jQuery('#divThreads').children().length == 1) { if(true) { // listen everywhere, this'll make it work together with 'expand images' function jQuery(".divPosts").on('DOMNodeInserted', function(e) { if(jQuery(e.target).hasClass('postCell')) unspoilPosts(); }) } var input=document.createElement('input'); input.type='checkbox'; input.id='DisableSpoilers'; input.onclick=unspoilPosts; input.checked=getSetting('myDisableSpoilers')==='true'; label.appendChild(input); label.appendChild(document.createTextNode('Unhide image spoilers')); c.parentNode.appendChild(label); unspoilPosts(); });