GogoRandom

A userscript that adds a random button to gogoanime, that one feature we all wanted years now but didn't get.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GogoRandom
// @namespace    https://github.com/ArjixWasTaken/my-userscripts
// @version      0.5
// @description  A userscript that adds a random button to gogoanime, that one feature we all wanted years now but didn't get.
// @author       Arjix
// @license      MIT
// @include      /.+:\/\/.*?gogoanime\..+/
// @grant        GM_xmlhttpRequest
// @require      https://code.jquery.com/jquery-3.5.1.min.js
// ==/UserScript==

function getRandomInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

(function() {
    'use strict';
    const link = "https://raw.githubusercontent.com/ArjixGamer/gogoanime-random/main/all_anime.json"
    const getRandomAnime = () => {
        GM_xmlhttpRequest({
            method: "GET",
            url: link,
            onload: function(res) {
                const ALL_ANIME = JSON.parse(res.response)
                const getDomainLink = () => {
                    return "https://" + document.location.href.match(/gogoanime[s]?\.[a-z]+/)?.[0]
                }
                const index = getRandomInt(1, ALL_ANIME.length-1)
                document.location.href = getDomainLink() + ALL_ANIME[index]
            }

    })}
    const button = `<li class="movies"><a title="Random Anime" href="#" class="random ads-evt">Random</a></li>`
    $("nav.menu_top > ul > li").last().after(button)
    document.querySelector("li.movies > a.random").onclick = getRandomAnime
})();