Greasy Fork

GogoAnime++

Replaces the download link with a direct download link.

目前为 2021-04-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         GogoAnime++
// @namespace    http://tampermonkey.net/
// @version      3.1
// @description  Replaces the download link with a direct download link.
// @author       Arjix
// @match        *://*.gogoanime.vc/*
// @match        *://*.gogoanime.tv/*
// @match        *://*.gogoanime.io/*
// @match        *://*.gogoanime.in/*
// @match        *://*.gogoanime.se/*
// @match        *://*.gogoanime.sh/*
// @match        *://*.gogoanime.video/*
// @match        *://*.gogoanime.movie/*
// @match        *://*.gogoanime.so/*
// @match        *://*.gogoanimes.co/*
// @match        *://*.gogoanime.ai/*
// @match        *://*.animego.to/*
// @grant        GM_xmlhttpRequest

// ==/UserScript==


(function() {
    'use strict';
    window.addEventListener("load", function () {
        const title = document.title
        const test = document.querySelector('div#load_recent_release')
        if (title.includes("Watch") && test == undefined) {
        const link = document.querySelector("li.dowloads").firstChild.href
        var ret = GM_xmlhttpRequest({
            method: "GET",
            url: link,
            onload: function(res) {
                var videoLinks = Array.from(res.response.matchAll(/<a\n.*?[\"'](http.*?)['\"].*?\n.*?(\(.*?\))/gm))
                var qualities = []
                videoLinks.forEach(link => {
                    let quality;
                    if (link[2].includes("720")) {
                        quality = 720
                    } else if (link[2].includes("480")) {
                        quality = 480
                    } else if (link[2].includes("360")) {
                        quality = 360
                    } else if (link[2].includes("HD") || link[2].includes("1080")) {
                        quality = 1080
                    }
                    let obj = {}
                    obj["src"] = 'https://bypass-cors.vercel.app/cors.py/cors.py?url=' + link[1]
                    obj["size"] = quality
                    obj["type"] = "video/mp4"
                    qualities.push(obj)
                })
                qualities.sort((a, b) => (a.size > b.size ? 1 : -1))
                qualities = qualities.reverse();
                console.log(qualities)
                var videoLink = videoLinks[0][1]

                var downloadButton = document.querySelector("li.dowloads").firstChild
                downloadButton.href = videoLink
                downloadButton.target = "_self"
                downloadButton.download = document.querySelector("div.anime_video_body > h1").innerText.replace(" at gogoanime", "") + ".mp4"
                document.querySelector("li.dowloads > a > span").innerText = "Direct Download"
  }
})}
    }, false)
})();