biuuu / shinycolors Goto Github PK
View Code? Open in Web Editor NEW偶像大师闪耀色彩汉化
Home Page: https://www.shiny.fun/ShinyColors.user.js
License: MIT License
偶像大师闪耀色彩汉化
Home Page: https://www.shiny.fun/ShinyColors.user.js
License: MIT License
报错Uncaught RangeError: Maximum call stack size exceeded
我的其他脚本都能工作正常, 但是这个翻译完全没有生效?
With the latest game update, the app is loaded directly through HTML, so hijacking eval no longer works.
In the English patch, I devised a solution by executing the patch script very early, and intercepting script loading with the "beforescriptexecute" event. This event is only natively available on Firefox, so I imported a polyfill to get the event on other browsers too.
The commit detailing the implementation in the English patch is snowyivu@808664c
I opened an issue first instead of directly sending a pull request because difference in implementation details made me unsure if this works in the Chinese patch too.
Consider 線たちの12月 Scenario event's last commu (game_event_communications/400105508.json):
There exists a line without an ID, which the original text is "──────" and the translation is also "──────".
Also, there exists two lines with IDs 4001055081061 and 4001055081062 respectively, that also has original text value of "──────" but has a proper translation (added for convenience reasons since it does have a voiceline)
When the translation CSV is read by the script, translations are put into a Map
where the key is the original text if ID is nonexistent, or the ID is the key if the key does exist:
Map entry of the first line without an ID (index 72)
Map entries of the lines with an ID (index 139 and 140)
The problematic part is here:
ShinyColors/src/modules/story.js
Lines 75 to 88 in f8da1d3
Since L81 which checks for the key with the exact match comes first, translations for 4001055081061 and 4001055081062 are ignored as there exists an exact match where only the original text ("──────") matches. Therefore the translation for the ID-less line is used for both of the lines, which is the same as before. This is how it looks in-game:
It feels like it would be fine to just swap the order of the checks, so ID check at L83-84 comes first before the text only check at L81-82, but I could be wrong.
SC 通过 eval
加载主程序代码,因此劫持 eval
就可以对目标代码进行替换。
为了绕过官方的拒绝加载,我们还需要实现劫持后 eval
函数的 toString
(具体的代码可以参考 app-xxxxxx.js 中 base64 段末尾的内容)。
window.eval = new Proxy(window.eval, {
apply(target, _this, [code]) {
if (code.includes("var n=window.primJsp")) {
code = code.replace(
"var n=window.primJsp",
"var n=window.primJsp;window._require=t"
);
}
return target(code);
},
});
window.eval.toString = () => "function eval() { [native code] }";
之后就可以通过 _require(moduleId)
直接获取模块内容了。
ShinyColors/src/modules/api-comm.js
Lines 58 to 71 in dbe377b
Here, we split
the string to translate by /
(Line 60) before looking for the substitution string on skill.csv. I imagine this is for translation of slash-separated skill effects, however this actually causes skill names containing slashes to be not translated correctly. For example, take a look at Nichika's 2nd P-SSR:
What happens is that since the skill name contains a forward slash ([7/31]超順調ですよ
), this gets split into two parts ([7
and 31]超順調ですよ
) before looking for substitutions; therefore, if you were to put translation data such as [7/31]超順調ですよ,[7/31]완전 순조로워요,text
in the skill.csv file, the script will fail to find the substitute as it's not looking for the complete string, rather in parts.
One workaround is to enter translations for the individual parts manually, like:
[7,[7,text
31]超順調ですよ,31]완전 순조로워요,text
However this would be super confusing as to why they're split like that, so I'd like the fix be made in the source instead if possible.
Suggested code would be something like:
const transItem = (item, key, data = commData) => {
if (item?.[key]) {
let arr = key == "name" ? [ item[key] ] : item[key].split('/')
arr.forEach((txt, index) => {
let plusList = nameWithPlus(arr)
replaceItem(arr, index, data)
nameWithPlus(arr, plusList)
})
let text = arr.join('/')
if (text !== item[key]) {
item[key] = tagText(text, true)
}
}
}
I'm not sure if this is really viable elsewhere as I do not know where else the transItem function is used in. As far as I know there's no name
s that needs to be translated in parts so I imagine this would be fine? 😅
以前一直正常运行,从9月20日更新结束开始,机翻失效,且脚本和拓展程序本身并没有报错。在对照过翻译组的剧情表和游戏内文本来看,只有只能依靠机翻的还是呈现日文。尝试过重新安装脚本、暴力猴,重启浏览器、电脑也并未起效。浏览过所有closed的issues后也未找到解决方法,故在此新建一个issue。(希望不是什么系统本身的问题)
浏览器:Chrome 已是最新版本
版本 105.0.5195.127(正式版本) (64 位)
扩展程序:暴力猴 2.13.1
ID:jinjaccalgkegednnccohejagnlnfdag
脚本: 偶像大师ShinyColors汉化 biuuu 1.10.3 96k(代码:95k 设置:1k)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.