-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfixes.js
299 lines (251 loc) · 8.77 KB
/
fixes.js
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
window.gui.playerData.once("characterSelectedSuccess", function() {
/* Zoom fix */
let worldZoom = function(worldMap, e) {
let zoom = - e.deltaY / 600;
let previousZ = worldMap._scene.camera.zoomTarget;
worldMap._scene.camera.zoomTo(worldMap._scene.camera.zoom * (1 + zoom));
let newZ = worldMap._scene.camera.zoomTarget;
let deltaZ = newZ / previousZ;
worldMap._scene.move(0, 0, e.layerX * (deltaZ - 1), e.layerY * (deltaZ - 1), 1);
worldMap._loadChunksInView();
};
let mapZoom = function(mapScene, e) {
let zoom = - e.deltaY / 600;
let previousZ = mapScene.camera.zoomTarget;
mapScene.camera.zoomTo(mapScene.camera.zoom * (1 + zoom));
let newZ = mapScene.camera.zoomTarget;
let deltaZ = newZ / previousZ;
};
window.gui.windowsContainer.getChildren().forEach(function(child) {
if (child.id == "worldMap") {
child.on('open', function() {
child._worldMap.rootElement.addEventListener('mousewheel', function(e) {
worldZoom.call(this, child._worldMap, e);
});
});
}
});
window.foreground.rootElement.addEventListener('mousewheel', function(e) {
mapZoom.call(this, window.isoEngine.mapScene, e);
});
});
/* Touches fix */
var events = {
"mousedown": "touchstart",
"mouseup": "touchend",
"mousemove": "touchmove"
};
var mouseDown = false;
var handleEvents = function(e) {
try {
if (e.type === "mousedown") mouseDown = true;
else if (e.type === "mouseup") mouseDown = false;
if (!mouseDown && e.type === "mousemove") return;
const touchObj = new Touch({
identifier: 0,
target: e.target,
clientX: e.clientX,
clientY: e.clientY,
pageX: e.pageX,
pageY: e.pageY,
screenX: e.screenX,
screenY: e.screenY,
radiusX: 11.5,
radiusY: 11.5,
rotationAngle: 0,
force: e.type === "mouseup" ? 0 : 1,
});
const touchEvent = new TouchEvent(events[e.type], {
cancelable: true,
bubbles: true,
touches: e.type === "mouseup" ? [] : [touchObj],
targetTouches: e.type === "mouseup" ? [] : [touchObj],
changedTouches: [touchObj],
shiftKey: false,
composed: true,
isTrusted: true,
sourceCapabilities: new InputDeviceCapabilities({ firesTouchEvents: true }),
view: window
});
e.target.dispatchEvent(touchEvent);
} catch (e) {
top.console.log(e);
}
e.stopPropagation();
// e.preventDefault();
return false;
};
try {
for (var id in events) {
document.body.addEventListener(id, handleEvents, true);
}
} catch (e) {
top.console.log(e);
}
/* Get stats */
/**
* The main goal of this code snippet is to understand how the users are using Lindo.
* The data is anonymized, each record is not intended to be treated individually.
*/
(function () {
/* DECLARATIONS */
// https://stackoverflow.com/a/52171480
const cyrb53 = function(str, seed = 0) {
let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1>>>16), 2246822507) ^ Math.imul(h2 ^ (h2>>>13), 3266489909);
h2 = Math.imul(h2 ^ (h2>>>16), 2246822507) ^ Math.imul(h1 ^ (h1>>>13), 3266489909);
return 4294967296 * (2097151 & h2) + (h1>>>0);
}
const Settings = window.top.eval("require('@electron/remote').require('electron-settings')")
/* Get VIP settings */
const vipSettingsOriginal = Settings.getSync('option.vip')
const vipSettings = JSON.parse(JSON.stringify(vipSettingsOriginal))
if (vipSettings.multi_account) {
delete vipSettings.multi_account.windows
// Prevent the master password from being sent over the network
if (vipSettings.multi_account.master_password) {
vipSettings.multi_account.master_password = 'REDACTED'
}
// Prevent any encoded password from being sent
if (vipSettings.multi_account.window && Array.isArray(vipSettings.multi_account.window)) {
vipSettings.multi_account.window.forEach(tabs => {
if (tabs && Array.isArray(tabs)) {
tabs.forEach(tab => {
if (tab.account_name_encrypted) tab.account_name_encrypted = 'REDACTED'
if (tab.password_encrypted) tab.password_encrypted = 'REDACTED'
})
}
})
}
// This data contains identifiable character name
if (vipSettings.auto_group.leader) {
vipSettings.auto_group.leader = 'REDACTED'
}
// This data contains identifiable characters names
if (vipSettings.auto_group.members) {
vipSettings.auto_group.members = 'REDACTED'
}
}
vipSettings.hidden_shop = Settings.getSync('option.general.hidden_shop')
/* Approximate unique ID */
const macAddress = Settings.getSync('macAddress')
const macAddressHash = cyrb53(macAddress, 7200084)
/* Send to server once logged in */
window.connectionManager.once('IdentificationSuccessMessage', (msg) => {
const body = {
mac_address_hash: macAddressHash,
account_id_hash: cyrb53('' + msg.accountId, 97333452),
vip_settings: vipSettings
}
fetch('https://api.lindo-app.com/stats.php', {
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
})
})();
/* Popups */
/**
* @param {Record<string, { title: string, messages: string[] }>} texts
* @param {{ url: string, text: string }} link
*/
async function sendPopup (texts, link) {
const languagesInitialized = new Promise(resolve => {
const interval = setInterval(() => {
if (window.Config && window.Config.language) {
clearInterval(interval);
resolve();
}
}, 1000);
});
const lindoLogoLoaded = new Promise(resolve => {
const lindoLogo = new Image();
lindoLogo.addEventListener('load', resolve);
lindoLogo.src = "https://lindo-app.com/icon.png";
});
await Promise.all([
languagesInitialized,
lindoLogoLoaded
]);
const translatedTexts = texts[window.Config.language] || texts['en'] || texts[Object.keys(texts)[0]];
window.gui.openSimplePopup(`
<div>
${translatedTexts.messages.join('<br />')}<br />
<a target="_blank" href="${link.url}" style="text-align: center; font-size: 1.2em; display: inline-block; width: 100%; margin-top: 0.4em; text-decoration: none;">
<img src="https://lindo-app.com/icon.png" style="height: 1.2em; display: inline-block; vertical-align: middle;"/>
<span style="vertical-align: middle;">${link.text}</span>
</a>
</div>
`, translatedTexts.title);
}
(function () {
const lastAskedMatrix = window.localStorage.getItem('lindo-matrix-popup');
if (!lastAskedMatrix || Date.now() > parseInt(lastAskedMatrix) + 1000 * 60 * 60 * 24 * 7) { // 1 week
window.localStorage.setItem('lindo-matrix-popup', Date.now())
const texts = {
fr: {
title: `Notification de Lindo`,
messages: [
`Un nouveau serveur de discussion a été mis en place pour remplacer Discord ! Retrouve nous vite sur le serveur Matrix de Lindo<br />`
]
},
en: {
title: `Notification from Lindo`,
messages: [
`A new chat server has been set up to replace Discord! Find us quickly on Lindo's Matrix server.<br />`
]
},
es: {
title: `Notificación de Lindo`,
messages: [
`¡Se ha configurado un nuevo servidor de chat para reemplazar a Discord! Encuéntrenos rápidamente en el servidor Matrix de Lindo.<br /> `
]
}
}
const link = {
url: 'https://matrix.to/#/#lindo-official:matrix.org',
text: 'Matrix Lindo'
}
sendPopup(texts, link)
return
}
})();
const showV3Update = async () => {
const lastAskedV3 = window.localStorage.getItem('lindo-v3');
if (!lastAskedV3 || Date.now() > parseInt(lastAskedV3) + 1000 * 60 * 60 * 24) { // 1 day
window.localStorage.setItem('lindo-v3', Date.now())
const texts = {
fr: {
title: `Notification de Lindo`,
messages: [
`La V2 de Lindo ne sera bientôt plus supporté par l'équipe, téléchargez la nouvelle version de Lindo sur GitHub<br />`
]
},
en: {
title: `Notification from Lindo`,
messages: [
`Lindo V2 will soon no longer be supported by the team, download the new version of Lindo on GitHub.<br />`
]
},
es: {
title: `Notificación de Lindo`,
messages: [
`Lindo V2 pronto dejará de ser compatible con el equipo, descargue la nueva versión de Lindo en GitHub.<br /> `
]
}
}
const link = {
url: 'https://github.com/prixe/lindo/releases/latest',
text: 'https://github.com/prixe/lindo/releases/latest'
}
await sendPopup(texts, link)
return
}
}