With 0.18 update the nsfw patch is missing yet, so in the meantime I found this userscript and modified it to work with NSFW.
P.S. I know this is not the best community for this, but nothing else fits.
Use your userscript manager of choice to install it. Violentmonkey, Tampermonkey
// ==UserScript==
// @name Lemmy Image Expand (modified)
// @namespace Violentmonkey Scripts
// @match *://*/*
// @grant none
// @version 1.0.1
// @author SlyFabi
// @description Auto expands all image posts including NSFW ones.
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Thanks to CodingAndCoffee for isLemmy
let isLemmy;
try {
isLemmy = document.head.querySelector("[name~=Description][content]").content === "Lemmy";
} catch (_er) {
isLemmy = false;
}
if(isLemmy) {
// https://stackoverflow.com/questions/18177174/how-to-limit-handling-of-event-to-once-per-x-seconds-with-jquery-javascript
function throttle(func, interval) {
var lastCall = 0;
var nextCall = -1;
return function() {
var now = Date.now();
clearTimeout(nextCall);
if (lastCall + interval < now) {
lastCall = now;
func.apply(this, arguments);
} else {
nextCall = setTimeout(function() {
lastCall = Date.now();
func.apply(this, arguments);
}, interval);
}
};
}
const targetNode = document.getElementById('app');
const config = { attributes: false, childList: true, subtree: true };
let observer = null;
const callback = throttle(function(mutationsList) {
if(observer != null) {
observer.disconnect();
}
setTimeout(function() {
let postList = [];
document.querySelectorAll('.post-listing a.text-body svg.icon use').forEach(function(postIcon) {
const imgPreview = postIcon.parentElement.parentElement;
if(postIcon.getAttribute('xlink:href') !== "/static/assets/symbols.svg#icon-image") {
return;
}
postList.push(imgPreview);
});
let uniqueList = postList.reduce((unique, o) => {
if(!unique.some(obj => obj.getAttribute('href') === o.getAttribute('href'))) {
unique.push(o);
}
return unique;
},[]);
uniqueList.forEach(function(imgPreview) {
const postListing = imgPreview.closest(".post-listing");
const isExpanded = postListing.querySelector('.img-expanded') != null;
if(!isExpanded) {
imgPreview.click();
}
//console.log('UElement: ' + imgPreview + ' Exp: ' + isExpanded);
});
/*postList.forEach(function(imgPreview) {
imgPreview.style.pointerEvents = 'none';
//console.log('Element: ' + imgPreview);
});*/
setTimeout(function() {
observer = new MutationObserver(callback);
observer.observe(targetNode, config);
}, 500);
}, 500);
}, 1000);
setTimeout(function() {
callback([]);
}, 500);
}
})();
It seems the update broke quite a few things especially instance based edits, I have faith they’ll be fixed sooner rather than later though. Such is the growing pains of newly mass adopted software, it seems. Fix ten things, break twenty things.
Removed by mod
Awesome temporary fix, works like a charm
This script has the same issue for me as the built-in auto expand: the images on screen (and some distance away) collapse when I vote on a post.
It’s the issue with the 0.18 Lemmy version. Hopefully it gets resolved with the new version.