-
-
Save BackEndTea/1979441e445403029b3b34a73a98265e to your computer and use it in GitHub Desktop.
picks random anime/manga from your MAL animelist/mangalist pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name MAL random | |
| // @version 3 | |
| // @description picks random anime/manga from your MAL animelist/mangalist pages | |
| // @author IA21 | |
| // @match https://myanimelist.net/mangalist/* | |
| // @match https://myanimelist.net/animelist/* | |
| // @grant none | |
| // ==/UserScript== | |
| // reference: http://stackoverflow.com/a/1527820/6179686 | |
| function getRandomInt(min, max) { | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } | |
| (function() { | |
| 'use strict'; | |
| var container = document.createElement("div"); | |
| var randButton = document.createElement("span"); | |
| var randHighButton = document.createElement("span"); | |
| randButton.innerHTML = "random (all)"; | |
| randHighButton.innerHTML = "random (only high priority)"; | |
| randButton.style.marginLeft = "15px"; | |
| randHighButton.style.marginLeft = "15px"; | |
| randButton.style.cursor = "pointer"; | |
| randHighButton.style.cursor = "pointer"; | |
| container.style.color = "white"; | |
| container.style.lineHeight = "38px"; | |
| container.style.position = "absolute"; | |
| container.appendChild(randButton); | |
| container.appendChild(randHighButton); | |
| var text = document.getElementsByClassName("text")[10]; | |
| document.getElementsByClassName("list-status-title")[0].insertBefore(container, text); | |
| randButton.onclick = function() { | |
| var titleList = document.getElementsByClassName("link sort"); | |
| var e = titleList[getRandomInt(0, titleList.length)]; | |
| e.target = "_blank"; | |
| e.click(); | |
| }; | |
| randHighButton.onclick = function() { | |
| var theChosenOnes = [], list = document.getElementsByClassName("list-item"); | |
| for (var i = 0 ; i < list.length ; i++) | |
| if(list[i].getElementsByClassName("data priority")[0].innerText == "High") | |
| theChosenOnes.push(list[i].children[0].children[3].children[0]); | |
| if(theChosenOnes.length !== 0) | |
| { | |
| var e = theChosenOnes[getRandomInt(0, theChosenOnes.length)]; | |
| e.target = "_blank"; | |
| e.click(); | |
| } | |
| else if(theChosenOnes.length === 0) | |
| alert("No High Priority Entry Found"); | |
| }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment