-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpatchnotes.js
More file actions
62 lines (56 loc) · 1.6 KB
/
patchnotes.js
File metadata and controls
62 lines (56 loc) · 1.6 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
import * as settings from 'src/utils/settings/index.js';
import wrap from 'src/utils/2.pokemon.js';
import { noop, scriptVersion } from 'src/utils/1.variables.js';
import style from 'src/utils/style.js';
import { toast } from 'src/utils/2.toasts.js';
import Translation from 'src/structures/constants/translation.ts';
import eventManager from 'src/utils/eventManager';
import * as changelog from './changelog.js';
wrap(function patchNotes() {
const setting = settings.register({
name: Translation.Setting('patches'),
key: 'underscript.disable.patches',
});
const installed = settings.register({
key: 'underscript.update.installed',
type: 'text',
hidden: true,
converter() {
const key = `underscript.update.${scriptVersion}`;
if (localStorage.getItem(key)) {
localStorage.removeItem(key);
return scriptVersion;
}
return undefined;
},
});
if (
setting.value() ||
!scriptVersion.includes('.') ||
installed.value() === scriptVersion
) return;
style.add(`
#AlertToast div.uschangelog span:nth-of-type(2) {
max-height: 300px;
overflow-y: auto;
display: block;
}
#AlertToast div.uschangelog extended {
display: none;
}
`);
changelog.get(scriptVersion, true)
.then((text) => eventManager.on('underscript:ready', () => notify(text)))
.catch(noop);
function notify(text) {
toast({
text,
title: Translation.Toast('patch.notes'),
footer: `v${scriptVersion}`,
className: 'uschangelog',
onClose() {
installed.set(scriptVersion);
},
});
}
});