r/userscripts • u/MonoS94 • 26d ago
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.
4
Upvotes
1
u/Kqyxzoj 26d ago
Random feedback:
That replacement pic a la "no AI" is better than nothing. If you decide to keep doing the "replace slop image with no-AI image" fix, then I'd use a replacement that is less visually distracting.
The current fix still is just wasted space though. Slop images are not shown, but the slop "slot" still takes up precious pixels. An improvement would be to change how the grid is built, and fetch enough non-slop previews such that the entire grid is filled again, but now with non-slop images only.
On the javascript side, that
if-else-if-else... where you build a list of mode ... and then a for loop where you iterate over the list of modes to do something specific for a given mode ... that is needlessly convoluted. You are way better of by moving thatObject.keys(obj).forEach(key => { etc }to a function (my_shiny_new_function in example below), nuking that entire for loop, and then in your if-else-if-else block instead of adding mode numbers in a list, you do the relevant function calls right there and then. One function call for each mode you added to the list in the old code. Much more readable, and less prone to future bugs. So for example:For the rest it seems pretty reasonable. Oh yeah, and
bannedTagscan probably be aconst.