Skip to content

Instantly share code, notes, and snippets.

@IA21
Created April 21, 2017 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IA21/3972cd0eec9122b46b3fb9d9e8698310 to your computer and use it in GitHub Desktop.
Save IA21/3972cd0eec9122b46b3fb9d9e8698310 to your computer and use it in GitHub Desktop.
Add random button to MAL animelist (bookmarklet)
javascript:(function(){
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var e = document.createElement("span");
e.innerHTML = "random&nbsp&nbsp&nbsp";
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