forked from 0xDC00/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPC_Steam_Unity_Ken_ga_Kimi.js
More file actions
128 lines (113 loc) · 4.48 KB
/
Copy pathPC_Steam_Unity_Ken_ga_Kimi.js
File metadata and controls
128 lines (113 loc) · 4.48 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// ==UserScript==
// @name Ken ga Kimi | Ken ga Kimi: Momoyo Tsuzuri
// @version
// @author [DC]
// @description Steam
// * Rejet | Beijing Happy Entertainment Technology
// * Unity (JIT), engine MV_?
//
// https://store.steampowered.com/app/1162650/Ken_ga_Kimi/
// https://store.steampowered.com/app/1387350/Ken_ga_Kimi_Momoyo_Tsuzuri/
// ==/UserScript==
const Mono = require('./libMono.js');
const {
setHook,
findClass,
// findMethod,
// findFunction,
// findField,
// createFunction
} = Mono;
const handlerChar = trans.send((s) => s, '200++');
// const kclass1 = findClass('', 'Objects.TextBox');
// const field1 = kclass1.findField('scenarioFile');
// console.log(JSON.stringify(kclass1, null, 2));
// console.log(JSON.stringify(field1, null, 2));
// console.log(field1.getValue(args[0]).readPointer().readMonoString());
// const kclass1 = findClass('', 'Objects.TextBox');
// const md1 = kclass1.findMethod('SetNameText');
// setHook(md1, (args) => {
// console.log('onEnter: Objects.TextBox.SetNameText');
// readString(args[1]);
// })
////// Multiple-hooks (port from ZDTL dll)
//// public void SetNameText(string src)
setHook('' /* Assembly-CSharp */, 'Objects.TextBox' /* NameSpace.Class */, 'SetNameText' /* Method */, -1 /* argCnt */, {
onEnter: (args) => {
console.log('onEnter: Objects.TextBox.SetNameText');
readString(args[1]);
}
});
//// public override void AddString(string character, string fontName, uint fontColor, uint withShadow, uint withLine, uint foreColor, uint shadowColor, uint lineColor)
setHook('', 'Objects.DecorativeText', 'AddString', -1, {
onEnter: (args) => {
console.log('onEnter: Objects.DecorativeText.AddLetter');
readString(args[1]);
}
});
//// public virtual void AddString(string character, string fontName, uint fontColor, uint withShadow, uint withLine, uint foreColor, uint shadowColor, uint lineColor)
setHook('', 'Objects.Text', 'AddString', -1, {
onEnter: (args) => {
console.log('onEnter: Objects.Text.AddString');
readString(args[1]);
}
});
//// public virtual void AddLetter(char character, string fontName, uint fontColor, uint withShadow, uint withLine, uint foreColor, uint shadowColor, uint lineColor)
let sp = 0; // thread filter
let timer1 = null;
const pBuf = Memory.alloc(8);
//const Text_GetSrcText = createFunction('', 'Objects.Text', 'GetSrcText', -1, 'pointer', ['pointer']); // on-screen text
setHook('', 'Objects.Text', 'AddLetter', 8, {
onEnter: function (args) {
//// problem (rubi), fix => once sp (chars => ruby)
if (sp === 0) {
sp = this.context.sp;
console.log('onEnter: Objects.Text.AddLetter'); // on-screen text
}
if (this.context.sp.equals(sp) === false) return;
clearTimeout(timer1);
timer1 = setTimeout(() => { sp = 0 }, 250); // reset sp
pBuf.writePointer(args[1]);
const c = pBuf.readUtf16String(2)[0];
handlerChar(c);
//// onLeave => call (problem: rubi - same object)
//this.thiz = args[0];
},
// onLeave: function () {
// const address = Text_GetSrcText(this.thiz);
// // problem: multiple time
// // <tips name="辞書127"><ruby value="ちっきょ">蟄居</ruby></tips>されてから<br>
// const s = address.readMonoString()
// //.replaceAll('<br>', ' ') // \n => <br>
// .replace(/<.+?>/g, '');
// ;
// singleHandler(s);
// }
});
//// public override ScenarioDeclaration.State Execute(Scene scene, Element element)
const Element_GetAttribute = Mono.use('', 'Scenario.Element').GetAttribute.implementation;
console.log('Element_GetAttribute', Element_GetAttribute);
setHook('', 'Scenario.CaseCommand', 'Execute', -1, {
onEnter: (args) => {
console.log('onEnter: Scenario.CaseCommand.Execute');
// string attribute = element.GetAttribute("value"); // first call
const address = getElementAttribute(args[2], 'value');
readString(address);
}
});
function getElementAttribute(thiz, attribute) {
const att = Memory.allocMonoString(attribute); // mono_gc
return Element_GetAttribute(thiz, att);
}
function readString(address) {
const s = address.readMonoString()
//.replace(/<.+?>|^\s+/g, '')
;
if (s !== '') handlerChar(s + '\r\n');
}
// Replacer
trans.replace((s) => {
return s
.replace(/<.+?>|^\s+|\r?\n+$/g, '') // htmlTag | trimBeginSpace | trimEndNewLine
;
});