forked from 0xDC00/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPC_Steam_Unity_Nobody.The.Turnaround.js
More file actions
82 lines (73 loc) · 2.11 KB
/
Copy pathPC_Steam_Unity_Nobody.The.Turnaround.js
File metadata and controls
82 lines (73 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// ==UserScript==
// @name Nobody - The Turnaround
// @version
// @author [DC]
// @description Steam
// * U.Ground Game Studio
// * Unity (IL2CPP)
//
// https://store.steampowered.com/app/1810580/Nobody__The_Turnaround/
// ==/UserScript==
const Mono = require('./libMono.js');
const {
setHook,
_module
} = Mono;
let set = new Set(), timerDialog;
let previous = '';
function processText(s, ctx) {
if (previous.includes(s) !== true) {
set.add(s);
}
clearTimeout(timerDialog);
timerDialog = setTimeout(function () {
const finalStr = [...set].join('\r\n');
previous = finalStr;
set = new Set();
trans.send(finalStr);
}, 250);
}
let setUI = new Set(), timerUI;
function processUI(s, ctx) {
s = s.replace(/<[^>]+./g, ''); // trim html tag
setUI.add(s);
clearTimeout(timerUI);
timerUI = setTimeout(function () {
const finalStr = [...setUI].join('\r\n');
setUI = new Set();
console.log('---');
trans.send(finalStr);
}, 150);
}
/* Hook1: Dialogue */
setHook('', '.LanguageTools', 'GetDialogLanguage', -1, {
onLeave(retVal) {
const ctx = this.returnAddress.sub(_module.base);
console.log('onEnter: LanguageTools.GetDialogLanguage', ctx, ctx.add(0x180000000));
const s = retVal.readMonoString();
processText(s, ctx);
}
});
/* Hook2: UI+... */
let previousLang = '';
setHook('', '.LanguageTools', 'GetLanguage', -1, {
onLeave(retVal) {
const ctx = this.returnAddress.sub(_module.base);
console.log('onEnter: LanguageTools.GetLanguage', ctx, ctx.add(0x180000000));
const s = retVal.readMonoString();
if (previousLang !== s) {
previousLang = s;
processUI(s, ctx);
}
}
});
setHook('', '.LanguageTools', 'GetUIText', -1, {
onLeave(retVal) {
const ctx = this.returnAddress.sub(_module.base);
console.log('onEnter: LanguageTools.GetUIText', ctx, ctx.add(0x180000000));
const s = retVal.readMonoString();
if (s !== '[ Next]') {
processUI(s, ctx);
}
}
});