m-team大图浏览

种子列表/详情/演员列表 大图浏览,标题翻译。

// ==UserScript==
// @name         m-team大图浏览
// @namespace    mteam
// @version      0.6.0-beta.7
// @description  种子列表/详情/演员列表 大图浏览,标题翻译。
// @author       AfAn
// @license      MIT
// @match        https://*.m-team.cc/*
// @connect      translate.google.com
// @connect      api.avgle.com
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_notification
// @grant        GM_setClipboard
// @grant        GM_getResourceURL

// ==/UserScript==

(function() {
    "use strict";
    const t = window.location.host;
    var e, n;
    e = window.history, n = e.pushState, e.pushState = function (t) {
        return "function" == typeof e.onpushstate && e.onpushstate({
            state: t
        }), n.apply(e, arguments)
    }, window.history.onpushstate = function (t) {
        setTimeout((function () {}), 0)
    };
    var o = {
            "/api/torrent/search": function (e) {
                !async function (e) {
                    if (0 !== window.location.href.indexOf(`https://${t}/browse/adult`)) return;
                    let n = JSON.parse(e);
                    if (!n || !("code" in n) || "0" != n.code) return !1;
                    document.querySelector("div.ant-spin-container table thead tr th:nth-of-type(2)").style.width = window.innerWidth >= 1400 ? "700px" : "500px", document.querySelector("div.app-content__inner div.mx-auto").style.maxWidth = "100%";
                    let o = [];
                    for (let t = 0; t < 30; t++) {
                        await r(1e3), o = document.querySelectorAll("div.ant-spin-container table tbody tr");
                        let t = +n.data.pageSize,
                            e = +n.data.total;
                        if (o.length == t) break;
                        if (e < t && o.length == e) break
                    }
                    o.forEach((async (e, o) => {
                        e.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").style.height = "auto", e.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").addEventListener("click", (function (e) {
                            e.stopPropagation(), window.open(`https://${t}.cc/detail/${n.data.data[o].id}`, "_blank")
                        })), e.querySelector("td:nth-of-type(2) div.ant-image-mask").remove();
                        const a = e.querySelector("td:nth-of-type(3)");
                        let i = a.querySelectorAll("span.ant-typography-ellipsis-single-line");
                        i[0].style.whiteSpace = "normal", i[0].style.overflow = "unset", i[0].style.textOverflow = "unset", i.length > 1 && (i[1].style.whiteSpace = "normal", i[1].style.overflow = "unset", i[1].style.textOverflow = "unset"), i[0].closest("a > div").style.display = "block", i[0].style.display = "block", a.querySelector("br") && a.querySelector("br").remove(), (() => {
                            let t = document.createElement("div"),
                                e = document.createElement("button");
                            e.innerText = "翻 译", e.classList.add("ant-btn", "css-n9csir", "ant-btn-default", "ant-btn-sm"), e.addEventListener("click", (async e => {
                                e.stopPropagation(), e.target.disabled = !0;
                                let n = i[0].querySelector("strong").innerText;
                                i.length > 1 && (n += " ||| " + i[1].innerText);
                                let o = await
                                function (t) {
                                    return new Promise(((e, n) => {
                                        t = t.replace("#", ""), GM_xmlhttpRequest({
                                            method: "GET",
                                            url: "https://translate.google.com/translate_a/single?client=gtx&dt=t&dt=bd&dj=1&source=input&hl=zh-CN&sl=auto&tl=zh-CN&q=" + t,
                                            headers: {
                                                cookie: ""
                                            },
                                            onload: function (t) {
                                                for (var n = JSON.parse(t.responseText), o = "", a = 0; a < n.sentences.length; a++) o += n.sentences[a].trans;
                                                e(o)
                                            },
                                            onerror: function (t) {
                                                n()
                                            }
                                        })
                                    }))
                                }(n);
                                o = o.replace("|||", "<br />"), t.innerHTML = o
                            })), t.style.marginTop = "2rem", t.appendChild(e), i[0].closest("a").parentNode.appendChild(t)
                        })(), 30 === o && await r(1e3)
                    }))
                }(e)
            },
            "/api/dmm/showcase/fetchList": function (e) {
                !async function (e) {
                    if (0 !== window.location.href.indexOf(`https://${t}/showcaseDetail?id=`)) return;
                    let n = JSON.parse(e);
                    if (!n || !("code" in n) || "0" != n.code) return !1;
                    document.querySelector("div.ant-spin-container table thead tr th:nth-of-type(2)").style.width = window.innerWidth >= 1400 ? "700px" : "500px", document.querySelector("div.app-content__inner div.mx-auto").style.maxWidth = "100%";
                    let o = [];
                    for (let t = 0; t < 30 && (await r(1e3), o = document.querySelectorAll("div.ant-spin-container table tbody tr"), o.length != n.data.list.length); t++);
                    o.forEach(((e, o) => {
                        e.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").style.height = "auto", e.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").addEventListener("click", (function (e) {
                            e.stopPropagation(), window.open(`https://${t}/detail/${n.data.list[o].id}`, "_blank")
                        })), e.querySelector("td:nth-of-type(2) div.ant-image-mask").remove()
                    }))
                }(e)
            },
            "/api/dmm/dmmInfo": function (e) {
                !async function (e) {
                    if (0 !== window.location.href.indexOf(`https://${t}/detail/`)) return;
                    let n = JSON.parse(e);
                    if (!n || !("code" in n) || "0" != n.code) return !1;
                    await r(1e3), document.querySelectorAll(".ant-image-img.\\!max-w-600").forEach((t => {
                        t.classList.remove("!max-w-600")
                    }));
                    const o = "picData" in n.data && n.data.picData ? n.data.picData.split(",") : [];
                    let a = !1;

                    function i(t) {
                        return t.replace(/([^\/]+?)(-)(\d+\.\w+)$/, ((t, e, n, o) => `${e}jp${n}${o}`))
                    }
                    o.forEach((t => {
                        const e = document.querySelector(`img[src="${t}"]`);
                        if (e) {
                            a || (e.closest(".grid").classList.remove("grid"), a = !0), e.src = i(t), e.parentElement.querySelector(".ant-image-mask").remove();
                            const n = e.closest(".ant-image"),
                                o = n.cloneNode(!0);
                            n.parentNode.replaceChild(o, n)
                        }
                    }))
                }(e)
            }
        },
        a = XMLHttpRequest.prototype.send,
        i = XMLHttpRequest.prototype.open;

    function r(t) {
        return new Promise((e => setTimeout(e, t)))
    }
    XMLHttpRequest.prototype.open = function (t, e) {
        return this.url = e, i.apply(this, arguments)
    }, XMLHttpRequest.prototype.send = function () {
        return this.addEventListener("load", (function () {
            4 === this.readyState && 200 === this.status && Object.keys(o).forEach((t => {
                this.url.includes(t) && o[t](this.response)
            }))
        })), a.apply(this, arguments)
    }
})();