r/userscripts • u/MonoS94 • Jul 07 '26
Pixiv slop block userscript
I was tired of seeing slop on pixiv so i've developer an userscript to remove it in some way, it can be found here
https://github.com/MonoS/Pixiv-Slop-Block
It does not work on mobile version of the site, but it does when switching to Desktop Mode.
I've never written an usescript before, but it was pretty simple, any suggestion is welcome.
5
Upvotes
View all comments
Show parent comment
1
u/Kqyxzoj Jul 08 '26
Yeah, nice, the new logo is much less visually distracting. I also like how the new one blends into the canvas background now. This is much better! On the visual side I have one last detail, that white heart symbol on the AI-slop images. Personally I would want to remove it on the AI-slop images. Again for visual distraction reasons. But maybe you want to keep it because it is uesful to you. In the event that you would like to get rid of the visual distraction of that white heart on slop-AI images ... that white heart probably is located in the same enclosing <div> or <span> as the image itself. So should be pretty easy to find / select that element. You could do: in the same for-loop as you use for the slop-AI image replacement, you just delete the element that contains the white heart thingy. So right after
illusts[key].url = noAIBannerSVG;. Another way would be to add a"noAIBanner"or something class to either the enclosing element or the heart thingy itself. And then add a ".noAIBanner" or similar CSS style element that turns it 100% transparent. I think addingfilter:and then withopacityvalue of 0, that should probably do the trick. That way the white heart element is still there, but it is totally transparent.As for javascript side, yeah, that's also a lot better. There are still a few things about the foreach loop that can be simplified, but I'll just mention the most straightforward change... Currently you iterate over the keys, but then only ever use the referenced value, not the key itself. In that case it is simpler to just iterate over the values right away, no need for that key intermediate step.
So
Object.keys(illusts).forEach(key => {would becomeObject.values(illusts).forEach(item => {. And then you replace everyillusts[key]withitem. That'll remove 5 explicit key lookups from the loop. After you've done that you'll probably notice that you now havebannedUsers.some(i => item.userId == i)in there. Which you can simplify tobannedUsers.includes(item.userId). There are more incremental improvements, but these were the main ones I think. Oh yeah, this one:.aiType==2. You may want to create a meaningfully named constant for that 2 value. That way anyone reading it at least will have some idea where that magic 2 value comes from.Bit longer than intended, but oh well.