Created
April 21, 2017 08:11
-
-
Save IA21/3972cd0eec9122b46b3fb9d9e8698310 to your computer and use it in GitHub Desktop.
Add random button to MAL animelist (bookmarklet)
This file contains 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
javascript:(function(){ | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
var e = document.createElement("span"); | |
e.innerHTML = "random   "; | |
e.style.color = "white"; | |
e.style.cursor = "pointer"; | |
var bef = document.getElementById("show-stats-button"); | |
document.getElementsByClassName("stats")[0].insertBefore(e, bef); | |
e.onclick = function() { | |
var list = document.getElementsByClassName("link sort"); | |
var e = list[getRandomInt(0, list.length)]; | |
e.target = "_blank"; | |
e.click(); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment