Skip to content

Commit 68f41d5

Browse files
committed
feat(lyrics-plus/translator): inject internals when using netease
1 parent 00199ce commit 68f41d5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CustomApps/lyrics-plus/Translator.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ const openCCPath = "https://cdn.jsdelivr.net/npm/opencc-js@1.0.5/dist/umd/full.m
66
const dictPath = "https:/cdn.jsdelivr.net/npm/kuromoji@0.1.2/dict";
77

88
class Translator {
9-
constructor(lang) {
9+
constructor(lang, isUsingNetease = false) {
1010
this.finished = {
1111
ja: false,
1212
ko: false,
1313
zh: false,
1414
};
15+
this.isUsingNetease = isUsingNetease;
1516

1617
this.applyKuromojiFix();
1718
this.injectExternals(lang);
1819
this.createTranslator(lang);
1920
}
2021

2122
includeExternal(url) {
22-
if (CONFIG.visual.translate && !document.querySelector(`script[src="${url}"]`)) {
23+
if ((CONFIG.visual.translate || this.isUsingNetease) && !document.querySelector(`script[src="${url}"]`)) {
2324
const script = document.createElement("script");
2425
script.setAttribute("type", "text/javascript");
2526
script.setAttribute("src", url);

CustomApps/lyrics-plus/Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const Utils = {
7070
*/
7171
async toSimplifiedChinese(s) {
7272
// create a singleton Translator instance
73-
if (!this._translatorInstance) this.translator = new Translator("zh");
73+
if (!this._translatorInstance) this.translator = new Translator("zh", true);
7474

7575
// translate to Simplified Chinese
7676
// as Traditional Chinese differs between HK and TW, forcing to use OpenCC standard

0 commit comments

Comments
 (0)