// ==UserScript==
// @name m-team大图浏览
// @namespace mteam
// @version 0.6.0-beta.6
// @description 种子列表/详情/演员列表 大图浏览,标题翻译。
// @author AfAn
// @license MIT
// @match https://kp.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";
var t, e;
t = window.history, e = t.pushState, t.pushState = function (n) {
return "function" == typeof t.onpushstate && t.onpushstate({
state: n
}), e.apply(t, arguments)
}, window.history.onpushstate = function (t) {
setTimeout((function () {}), 0)
};
var n = {
"/api/torrent/search": function (t) {
!async function (t) {
if (0 !== window.location.href.indexOf("https://kp.m-team.cc/browse/adult")) return;
let e = JSON.parse(t);
if (!e || !("code" in e) || "0" != e.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 n = [];
for (let t = 0; t < 30; t++) {
await r(1e3), n = document.querySelectorAll("div.ant-spin-container table tbody tr");
let t = +e.data.pageSize,
o = +e.data.total;
if (n.length == t) break;
if (o < t && n.length == o) break
}
n.forEach((async (t, n) => {
t.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").style.height = "auto", t.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").addEventListener("click", (function (t) {
t.stopPropagation(), window.open(`https://kp.m-team.cc/detail/${e.data.data[n].id}`, "_blank")
})), t.querySelector("td:nth-of-type(2) div.ant-image-mask").remove();
const o = t.querySelector("td:nth-of-type(3)");
let i = o.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", o.querySelector("br") && o.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) => {
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 = "", i = 0; i < n.sentences.length; i++) o += n.sentences[i].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 === n && await r(1e3)
}))
}(t)
},
"/api/dmm/showcase/fetchList": function (t) {
!async function (t) {
if (0 !== window.location.href.indexOf("https://kp.m-team.cc/showcaseDetail?id=")) return;
let e = JSON.parse(t);
if (!e || !("code" in e) || "0" != e.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 n = [];
for (let t = 0; t < 30 && (await r(1e3), n = document.querySelectorAll("div.ant-spin-container table tbody tr"), n.length != e.data.list.length); t++);
n.forEach(((t, n) => {
t.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").style.height = "auto", t.querySelector("td:nth-of-type(2) img.torrent-list__thumbnail").addEventListener("click", (function (t) {
t.stopPropagation(), window.open(`https://kp.m-team.cc/detail/${e.data.list[n].id}`, "_blank")
})), t.querySelector("td:nth-of-type(2) div.ant-image-mask").remove()
}))
}(t)
}
},
o = 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(n).forEach((t => {
this.url.includes(t) && n[t](this.response)
}))
})), o.apply(this, arguments)
}
})();