Last active
April 14, 2025 23:48
-
-
Save CodeZombie/1c1fa714fc8c92275e99 to your computer and use it in GitHub Desktop.
Expand All Images in 4chan Thread Greasemonkey Extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Expand All Images | |
// @namespace zombiearmy.expandimage | |
// @description Expand all images in a 4chan thread | |
// @match *://boards.4chan.org/* | |
// @match *://boards.4channel.org/* | |
// @version 2 | |
// @grant none | |
// ==/UserScript== | |
var expanded = false; | |
//add expand buttons for desktop | |
var navlink = document.getElementsByClassName("navLinks desktop"); | |
for(var i = 0; i < navlink.length; i++) { | |
navlink[i].innerHTML += " [<a href='javascript:toggleImages()'>Toggle Images</a>] "; | |
} | |
//add expand buttons for mobile | |
navlink = document.getElementsByClassName("navLinks mobile"); | |
for(i = 0; i < navlink.length; i++) { | |
navlink[i].innerHTML += '<span class="mobileib button"><a href="javascript:toggleImages()">Expand Images</a></span>'; | |
} | |
window.toggleImages = function() { | |
var thumbs = document.getElementsByClassName("fileThumb"); | |
if(!expanded) { | |
expanded = true; | |
for(var i = 0; i < thumbs.length; i++) { | |
var img = thumbs[i].getElementsByTagName('img')[0]; | |
if (img.alt != "File deleted.") { | |
ImageExpansion.expand(img); | |
} | |
} | |
}else{ | |
expanded = false; | |
var collapseWebm = document.getElementsByClassName("collapseWebm"); | |
var expandedWebm = document.getElementsByClassName("expandedWebm"); | |
while(collapseWebm.length > 0){ | |
collapseWebm[0].remove(); | |
} | |
while(expandedWebm.length > 0){ | |
expandedWebm[0].remove(); | |
} | |
for(var i = 0; i < thumbs.length; i++) { | |
if(thumbs[i].style.display=="none"){ | |
thumbs[i].style.display = null; | |
} | |
var img = thumbs[i].getElementsByTagName('img')[1]; | |
if (img !== undefined) { | |
ImageExpansion.contract(img); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure if anyone is still using this in 2022 (I'm not!) but I just updated it with Maurogch's fixes (thank you!!!!) because this page still seems to still come up on google searches, so it might as well be functional :)