Skip to content

Instantly share code, notes, and snippets.

@divinity76
Last active December 30, 2023 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/1ac3270b1e95aab14866ef8ce8679278 to your computer and use it in GitHub Desktop.
Save divinity76/1ac3270b1e95aab14866ef8ce8679278 to your computer and use it in GitHub Desktop.
4chan expandAll - expand all thumbnailed images
// why max? firefox has issues if you try to click 100+ images at the same time (chrome doesn't, but firefox does, why? idk)
function expandAllImages(max=1){
let all=document.querySelectorAll("div.file:not(.image-expanded) img:not(.autoexpanded)");
max=Math.min(max,all.length);
for(let i=0;i<max;++i){
all[i].className+=" autoexpanded";
//all[i].parentNode.dispatchEvent(new MouseEvent("click", {ctrlKey: true}));
all[i].click();
}
return max;
}
function expandAllImagesPeriodically(){
if(window.stopAutoExpand){
console.log("expandAllImagesPeriodically stopped via window.stopAutoExpand");
return;
}
setTimeout(expandAllImagesPeriodically,5000);
let expanded=expandAllImages();
if(expanded!==0){
console.log("auto-expanded: "+expanded);
}
}
expandAllImagesPeriodically();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment