-
-
Save Mitame/2e3d9148dbd3a616ac9e393c5440e2b6 to your computer and use it in GitHub Desktop.
Add random button to MAL animelist
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
// ==UserScript== | |
// @name MAL random | |
// @version 1 | |
// @description adds random button on MAL animelist | |
// @author IA21 | |
// @match https://myanimelist.net/animelist/* | |
// @grant none | |
// ==/UserScript== | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
(function() { | |
'use strict'; | |
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