\u5BFC\u6F14: ${data.director}
\u7C7B\u578B: ${data.genre}
\u5236\u7247\u56FD\u5BB6/\u5730\u533A: ${data.region}
\u8BED\u8A00: ${data.language}
\u65F6\u957F: ${data.runtime}
\u53C8\u540D: ${data.aka}
`);
if (data.average) {
$("#movie-ratings-table tr").prepend(`
\u8C46
\u8C46\u74E3\u8BC4\u5206
|
${data.average}
/
10
(${data.votes} votes) | `);
}
};
var getImdbId = () => {
let imdbLink = "";
const imdbConfig = CURRENT_SITE_INFO.imdb;
if (typeof imdbConfig === "object") {
try {
Object.keys(imdbConfig).forEach((key) => {
if ($(`${imdbConfig[key]}`)[0]) {
imdbLink = $(imdbConfig[key]).attr("href");
throw new Error("end loop");
}
});
} catch (error) {
if (error.message !== "end loop") {
console.log(error);
}
}
} else {
imdbLink = $(imdbConfig).attr("href");
}
console.log(imdbLink);
return /tt\d+/.exec(imdbLink)[0];
};
var getDoubanId = (imdbId) => {
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "GET",
url: `${DOUBAN_SEARCH_API}?q=${imdbId}`,
onload(res) {
try {
const data = JSON.parse(res.responseText);
if (data.length > 0) {
resolve(data[0]);
}
} catch (error) {
console.log(error);
}
}
});
});
};
var getTvSeasonData = (data) => {
const {titleDom} = CURRENT_SITE_INFO;
const torrentTitle = $(titleDom).text();
return new Promise((resolve, reject) => {
var _a3, _b2;
const {episode = "", title} = data;
if (episode) {
const seasonNumber = (_b2 = (_a3 = torrentTitle.match(/S(?!eason)?0?(\d+)\.?(EP?\d+)?/i)) == null ? void 0 : _a3[1]) != null ? _b2 : 1;
if (parseInt(seasonNumber) === 1) {
resolve(data);
} else {
const query = title.replace(/第.+?季/, `\u7B2C${seasonNumber}\u5B63`);
getDoubanId(query).then((data2) => {
resolve(data2);
});
}
}
});
};
var getDoubanInfo = (doubanId) => {
return new Promise((resolve, reject) => {
try {
if (doubanId) {
GM_xmlhttpRequest({
method: "GET",
url: `${DOUBAN_API_URL}/${doubanId}`,
onload(res) {
var _a3;
const data = JSON.parse(res.responseText);
if (data && ((_a3 = data.data) == null ? void 0 : _a3.id)) {
resolve(formatDoubanInfo(data.data));
} else {
console.log("\u8C46\u74E3\u6570\u636E\u83B7\u53D6\u5931\u8D25");
}
}
});
} else {
reject(new Error("\u8C46\u74E3\u94FE\u63A5\u83B7\u53D6\u5931\u8D25"));
}
} catch (error) {
console.log(error);
reject(new Error(error.message));
}
});
};
var formatDoubanInfo = (data) => {
let {title, votes, average, originalTitle} = data;
if (originalTitle !== title) {
title = title.replace(originalTitle, "").trim();
}
votes = votes || "0";
average = average || "0.0";
return __assign(__assign({}, data), {
chineseTitle: title,
votes,
average
});
};
var createDoubanDom = (doubanId) => {
const iframe = document.createElement("iframe");
iframe.id = "doubanIframe";
iframe.width = "770";
iframe.height = "345";
iframe.frameborder = "0";
iframe.scrolling = "no";
const div = document.createElement("div");
let {doubanContainerDom, insertDomSelector, siteName, poster} = CURRENT_SITE_INFO;
if (siteName === "HDT") {
insertDomSelector = $(insertDomSelector).parent();
}
$(insertDomSelector).before(doubanContainerDom);
const doubanLink = `https://movie.douban.com/subject/${doubanId}`;
GM_xmlhttpRequest({
url: `${doubanLink}/output_card`,
method: "GET",
onload(res) {
const htmlData = res.responseText.replace(/wrapper/g, "douban-wrapper").replace(/
/g, "");
let headDom = htmlData.match(/((.|\n)+)<\/head>/)[1];
headDom = headDom.replace(//g, "");
const bodyDom = htmlData.match(/((.|\n)+)<\/body>/)[1];
div.insertAdjacentHTML("beforeend", headDom);
div.insertAdjacentHTML("beforeend", bodyDom);
$(".douban-dom").append(div).attr("douban-link", doubanLink);
if ($(poster).attr("src")) {
let posterStyle = $(".picture-douban-wrapper").attr("style");
posterStyle = posterStyle.replace(/\(.+\)/, `(${$(poster).attr("src")})`);
$(".picture-douban-wrapper").attr("style", posterStyle);
}
$(".douban-dom").click(() => {
GM_openInTab(doubanLink);
});
}
});
iframe.onload = () => {
};
};
// src/style.js
var style_default = GM_addStyle(`
.contentlayout.douban-info {
display: flex;
justify-content: space-around;
}
.contentlayout.douban-info .detail{
flex:1;
}
.detail .title{
font-size: 26px;
font-weight: 600;
margin-bottom: 20px;
}
.detail .title a{
text-decoration: none;
}
.movie-detail{
display: flex;
justify-content: space-between;
}
.movie-detail .synopsis {
width: 60%;
}
.movie-detail .movieinfo {
margin-right: 20px;
max-width: 30%;
}
.icon-pt1{
font-size: 14px;
display: inline-block;
text-align: center;
border: 1px solid #41be57;
background-color: #41be57;
color: white;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
width: 24px;
height: 24px;
line-height: 24px;
}
.icon-pt2{
display: inline-block;
text-align: center;
border: 1px solid #41be57;
color: #3ba94d;
background: #ffffff;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
width: 69px;
height: 24px;
line-height: 24px;
font-size: 14px;
}
.douban-dom {
display: flex;
cursor: pointer;
}
.douban-dom {
text-align: left;
}
#douban-wrapper *{
box-sizing: content-box;
}
#douban-wrapper .clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden
}
#douban-wrapper .clearfix {
zoom: 1;
display: inline-block;
_height: 1px;
}
#douban-wrapper .clearfix {
height: 1%
}
#douban-wrapper .clearfix {
display: block
}
#douban-wrapper .rating_per{
color: #111;
}
#douban-wrapper .grid{
overflow: initial;
}
`);
// src/index.js
(async () => {
if (CURRENT_SITE_INFO) {
const imdbId = getImdbId();
const movieData = await getDoubanId(imdbId);
let {id, episode = ""} = movieData;
if (episode) {
const tvData = await getTvSeasonData(movieData);
id = tvData.id;
}
if (CURRENT_SITE_NAME === "PTP") {
getDoubanInfo(id).then((doubanData) => {
addToPtpPage(doubanData);
});
} else {
createDoubanDom(id);
}
}
})();
})();