Giter VIP home page Giter VIP logo

shinycolors's People

Contributors

biuuu avatar dependabot[bot] avatar lzgzhyf avatar yesterday17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shinycolors's Issues

感谢祭训练叶月出现时报错卡死

image
Uncaught (in promise) TypeError: i.includes is not a function
at Object.apply (偶像大师ShinyColors汉化.user.js:19:92669)
at t.value (5013-52db84366dbbb08862a3.chunk.js:1:236184)
at 5013-52db84366dbbb08862a3.chunk.js:1:233414
at async Promise.all (index 1)

Solution for module acquistion in latest update

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.

Translations with exact text match only are prioritised over translations with id match

Consider 線たちの12月 Scenario event's last commu (game_event_communications/400105508.json):

image
There exists a line without an ID, which the original text is "──────" and the translation is also "──────".

image
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:

image
Map entry of the first line without an ID (index 72)

image
Map entries of the lines with an ID (index 139 and 140)

The problematic part is here:

const startTrans = (data, storyMap, commMap) => {
const getId = uniqueStoryId()
data.forEach(item => {
if (item.text) {
const id = getId(item.id)
const text = fixWrap(item.text)
if (storyMap.has(text)) {
item.text = storyMap.get(text)
} else if (id && storyMap.has(`${id}`)) {
item.text = storyMap.get(`${id}`)
} else if (commMap.has(text)) {
item.text = commMap.get(text)
}
}

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:
image

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.

更新后 app-2f6ccab040ae019fe090.js 的模块获取解决方案

原理

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) 直接获取模块内容了。

Translation of skill names containing forward slashes does not work correctly

const transItem = (item, key, data = commData) => {
if (item?.[key]) {
let arr = 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)
}
}
}

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:
Screenshot_20220724_202536

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 names 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)

机翻偶然失效

浏览器、插件与脚本版本版本 Edge,暴力猴(油猴也测了),1.11.1

如图,在灯织主页语音4(偶像之路)时,没能显示出机翻

屏幕截图 2022-11-28 210700

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.