利用 TMDB 接口把 Sonarr 中的标题替换成其他语言标题
< Opiniones de Sonarr-Title-i18n
// ==UserScript==
// @name Sonarr-Title-i18n
// @name:zh Sonarr 标题国际化
// @description 利用 TMDB 接口把 Sonarr 中的标题替换成其他语言标题
// @namespace https://github.com/LuckyPuppy514
// @version 1.0.5
// @homepage https://github.com/LuckyPuppy514/Sonarr-Title-i18n
// @author LuckyPuppy514
// @copyright 2022, Grant LuckyPuppy514 (https://github.com/LuckyPuppy514)
// @license MIT
// @icon https://github.rn.lckp.top/LuckyPuppy514/dashboard-icons/master/png/sonarr.png
// @include *://*sonarr*
// @include *://*:8989/*
// @run-at document-end
// @require https://unpkg.com/[email protected]/dist/jquery.min.js
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_listValues
// @downloadURL https://update.greasyforks.org/scripts/450716/Sonarr-Title-i18n.user.js
// @updateURL https://update.greasyforks.org/scripts/450716/Sonarr-Title-i18n.meta.js
// ==/UserScript==
'use strict';
// 添加调试信息
console.log('Sonarr-Title-i18n script loaded on:', window.location.href);
// 默认语言代码
const DEFAULT_LANGUAGE_CODE = "zh-CN";
// GM_setValue key
const KEY_TMDB_API_KEY = "KEY_TMDB_API_KEY";
const KEY_LANGUAGE_CODE = "KEY_LANGUAGE_CODE";
const KEY_ERROR_MESSAGE = "KEY_ERROR_MESSAGE";
const KEY_TITLE_PREFIX = "TITLE_";
const KEY_TVDBID_PREFIX = "TVDBID_";
const KEY_OVERVIEW_PREFIX = "OVERVIEW_";
// className
const RIGHT_HEADERF_CLASS_NAME = "PageHeader-right-e8LU4";
const POSTER_TITLE_CLASS_NAME = "SeriesIndexPoster-title-rhAQh";
const OVERVIEW_TITLE_CLASS_NAME = "SeriesIndexOverview-title-LQthD SeriesIndexOverview-link-ltHLM Link-link-RInnp Link-link-RInnp Link-to-kylTi";
const DETAILS_TITLE_CLASS_NAME = "SeriesDetails-title-pJv1g";
const CALENDAR_TITLE_CLASS_NAME = "CalendarEvent-seriesTitle-QSWzp";
const CALENDAR_TITLE_AGENDA_CLASS_NAME = "AgendaEvent-seriesTitle-uBPt0";
const DETAILS_OVERVIEW_CLASS_NAME = "SeriesDetails-overview-cQJdA";
const SERIES_TITLE_CLASS_NAME = "Link-link-RInnp Link-to-kylTi";
// url path
const DETAILS_TITLE_PATH = "/series/";
const CALENDAR_TITLE_PATH = "/calendar";
const SERIES_TITLE_PATH = "/serieseditor, /seasonpass, /queue, /history, /blocklist, /missing, /cutoffunmet";
// element id
const i18n_BUTTON_ID = "i18n-button";
const SETTING_HIDDEN_DIV_ID = "setting-hidden-div";
const SETTING_SHOW_DIV_ID = "setting-show-div";
const CLOSE_BUTTON_ID = "close-button";
const SAVE_BUTTON_ID = "save-button";
const CLEAR_CACHE_BUTTON_ID = "clear-cache-button";
const TMDB_API_KEY_INPUT_ID = "tmdb-api-key";
const LANGUAGE_CODE_INPUT_ID = "language-code";
const ERROR_MESSAGE_TEXTAREA_ID = "error-message";
// css
const CSS = `
#i18n-button {
width: 25px;
height: 25px;
margin-top: 17px;
margin-left: -15px;
margin-right: 17px;
border: 0px;
border-radius: 50%;
background: rgba(255,255,255, 0);
background-repeat: no-repeat;
cursor: pointer;
z-index: 999
}
#i18n-button-svg {
width: 23px;
height: 23px;
}
#setting-div {
display: flex;
justify-content: center;
}
#setting-hidden-div {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
background-color: #000000;
opacity: 0.3;
display: none;
}
#setting-show-div {
width: 500px;
height: 260px;
background-color: rgba(64, 68, 84, 0.9);
display: none;
flex-direction: column;
border-radius: 5px;
align-items: center;
padding-top: 40px;
box-sizing: border-box;
position: absolute;
top: 200px;
}
#close-button {
position: absolute;
top: 7px;
right: 7px;
width: 28px;
height: 28px;
border-radius: 50%;
background-size: cover;
background-image: url(https://cdn.jsdelivr.net/gh/LuckyPuppy514/pic-bed/common/icons8-close-48.png);
background-repeat: no-repeat;
background-color: rgba(91, 137, 254, 0);
color: rgba(255, 255, 255, 0);
font-weight: normal;
}
#close-button:hover {
background-color: rgba(255, 255, 255, 0.5);
cursor: pointer;
}
#setting-show-div input {
width: 280px;
height: 25px;
border-radius: 5px;
border: none;
outline: none;
padding-left: 5px;
background-color: rgba(0, 0, 0, 1);
color: rgba(255, 255, 255, 1);
}
#setting-show-div input::-webkit-input-placeholder {
color: rgb(255, 255, 255);
opacity: 0.4;
}
#setting-show-div input:first-child {
margin-top: 5px;
margin-bottom: 5px;
}
#save-button {
cursor: pointer;
width: 300px;
height: 30px;
border-radius: 5px;
border: none;
outline: none;
margin-left: 5px;
padding-left: 5px;
background-color: rgba(0, 255, 0, 0.8);
color: rgba(255, 255, 255, 1);
}
#clear-cache-button:hover {
background-color: rgba(255, 255, 255, 0.5);
cursor: pointer;
}
#clear-cache-button {
position: absolute;
bottom: 8px;
right: 8px;
width: 30px;
height: 30px;
border-radius: 50%;
background-size: cover;
background-image: url(https://cdn.jsdelivr.net/gh/LuckyPuppy514/pic-bed/common/icons8-broom-64.png);
background-repeat: no-repeat;
background-color: rgba(91, 137, 254, 0);
color: rgba(255, 255, 255, 0);
font-weight: normal;
}
strong:hover:after {
position: absolute;
left: 30px;
top: -25px;
padding: 0px;
border: 1px solid rgb(255, 255, 255);
background-color: rgba(0,0,0,0.8);
border-radius: 3px;
color: rgba(255, 255, 255, 1);
content: attr(data-tips);
text-align: center;
z-index: 2;
width: 90px;
height: 30px;
}
#error-message {
width: 280px;
height: 50px;
border-radius: 5px;
border: none;
outline: none;
padding-left: 5px;
margin-top: 5px;
margin-bottom: 5px;
background-color: rgba(0, 0, 0, 1);
color: rgba(255, 255, 255, 1);
}
#setting-table {
width: 420px;
height: 100px;
border: none;
}
`
// html
const i18n_BUTTON = `
`
const SETTING_DIV = `
为什么安装后右上角没有这个按钮