Random anime button (or manga) user script. *Deprecated*

allthemighty

Alright, so inspired by this thread, i added a way to more easily get a random anime or manga from your list.



What you'll need is a way to install and run user scripts. For Chome this can be Tampermonkey, for Firefox Greasemonkey.

Then head to my GitHub repository and click on the "raw" button.


A popup from your user script manager should appear, if not you'll need to install it manually.

For the script use itself, click on a category! (otherwise it selects from everything) and then click on the button near the list title.

Keep in mind this is my first user script, so don't expect too much yet. But otherwise i hope this is useful to someone.

Known problems as of now:
- Button not working properly with really large lists

This script is currently obsolete because AniList now has their own random button (this is no coincidence i swear (¬‿¬) ). I'll leave this up for.... educational purposes maybe? idk really.

33 Replies
zaviier
Top NEET

can i edit your script and make my version?

edit:
nvm, my version so trashy

allthemighty

Lol it's not like my javascript is good either. But well go ahead, trying is improving.

zaviier
Top NEET

yep, i just edit random number 1 - 100000 for get random anime...
not perfect, will get 404 page

allthemighty

Yeah you pretty much always want to get the list length in this case. Otherwise as you said, you'll get 404's, because your index points to nothing ¯\_(ツ)_/¯

Tjerbowo

I love you

allthemighty

Thanks, i love you too

Tjerbowo

That's gay
I appreciate it <3

DeKleineKobini

Thank you for making this.

I made my own version of this script, in an attempt to fix it sometimes not working and while it's done in a non optimal way, it works.
https://github.com/kobini2/AniList-Random

allthemighty

Good going, sadly the problem isn't as easy to fix with just a timeout (updated bug description in OP). It seems that whenever you traverse to your list from an other tab, it doesn't even run the script, and well i'm having some real trouble fixing this lol.

*Edit: Seems this is about AJAX calls, no idea why i didn't think of that, anyway this should be fixable?

DeKleineKobini

While it indeed doesn't work when you just click the list, it now always works when refreshing, which it didn't for me before.

allthemighty

Ok i updated the script, which now takes care of my original issue. Made use of waitForKeyElements.js that helps detect when the AJAX calls are done. Could you update and try to reproduce your issue?

DeKleineKobini

There are still some problems:

  1. the match tag is no longer correct, you should set it to the while of anilist.co I think
  2. it only works once (switching back and forth doesn't work)
allthemighty

Updated. This takes care of almost all of the problems i think... i hope

The only thing i noticed is that the script doesn't run when you have another tab with anilist open. Not really sure how i'm gonna fix that yet though.

Edit: Yeah ok nevermind, definitely not fixed much. Got an idea?

DeKleineKobini
Tjerbowo

I LOVE YOU

sunnysummerday

I can't get the button to appear no matter how many times I refresh. Tested in both Vivaldi and Firefox. (And yes, Tamper/Greasymonkey is showing it as active on my list page.) Nevermind, it seems the button is in a different place compared to the screenshot ._.

allthemighty

Yeah my bad, i'll update the gif right now.

allthemighty

God bless, didn't think of an interval.

Anyway, the button still didnt appear if you opened anilist newly, and then headed to the list. I fixed all of this in my latest version, thanks to you lol.

sunnysummerday

I have my list sorted by score and it's only giving me random anime that I rated the highest.

allthemighty

Could you elaborate a bit? Because i'm not entirely sure what your problem is:

You clicked on a category as shown (EG paused), and you have sorted by score, then is there anything that's not supposed to happen?

sunnysummerday

It's only grabbing 9's and 10's. If I sort by title, it only grabs A's and B's.

allthemighty

I honestly can't seem to reproduce your issue, using your list it's working fine for me.

What browser are you on? And does the console show anything relevant?

sunnysummerday

Vivaldi (though Firefox does the same.) Here's the console in Vivaldi, with that huge number infinitely raising.

allthemighty

Uhm that was at least an older version of the script, could you update first and then see if it works?

DeKleineKobini

I think I know why this bug occurs. If you have many anime on your list, it doesn't load them all, only when you scroll further down. This makes that the script can't see many anime, and why it always shows 9 and 10's for some people.

allthemighty

Hmm i see, thats sounds pretty plausible

sunnysummerday

That's actually with the newest version, ' 1.2.2' :/

allthemighty

But i could swear i removed the console message like that in the latest version lol. Anyway @DeKleineKobini got a solid reasoning for this problem.

Birb

Thanks a lot for this.

Lemon
mod
食べないでください

This is now live in user list panels. (Not browse as of yet.)

You can restrict it by using any of the selections and filters available.

allthemighty

tfw

DeKleineKobini

Thank you for this, while this script was nice it's always nice to see it implemented in the site itself.

Mahdiii
Donator

When you want to make scripts like this but are too lazy to learn javascript.. Why did I have to focus 2 years of my life on Java and not JS :( (Also ik they are very similar im just too lazy)