Skip to content

Commit 65b42ad

Browse files
committed
feat: notify about notification feature
1 parent e029ab0 commit 65b42ad

File tree

5 files changed

+76
-9
lines changed

5 files changed

+76
-9
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# UnderScript Changelog
22

3+
## Version 0.60.3 (2025-03-17)
4+
1. Due to popular demand, you are now prompted to keep `@underscript`
5+
36
## Version 0.60.2 (2025-03-16)
47
1. Fixed quest progress noification (probably)
58

src/base/chat/notify.new.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as settings from '../../utils/settings/index.js';
33
import { global, globalSet } from '../../utils/global.js';
44
import pendingIgnore from '../../utils/pendingIgnore.js';
55
import pingRegex from '../../utils/pingRegex.js';
6+
import { pingExtras } from './toast.js';
7+
import { infoToast } from '../../utils/2.toasts.js';
68

79
const setting = settings.register({
810
name: 'Disable Chat Ping <span style="color: yellow;">(highlighting)</span>',
@@ -13,11 +15,16 @@ const setting = settings.register({
1315
const mask = '<span style="color: yellow;">$1</span>';
1416

1517
let disabled = false;
18+
let notified = false;
1619

1720
eventManager.on('preChat:getHistory Chat:getHistory', function enable(data) {
1821
if (disabled || global('soundsEnabled')) {
19-
globalSet('soundsEnabled', this.event === 'Chat:getHistory');
22+
if (disabled === false) {
23+
globalSet('soundsEnabled', this.event === 'Chat:getHistory');
24+
}
2025
disabled = !disabled;
26+
} else {
27+
disabled = 'history';
2128
}
2229
});
2330

@@ -31,6 +38,7 @@ eventManager.on('ChatDetected', () => {
3138
if (global('soundsEnabled') && original === text) {
3239
(new Audio('sounds/highlight.wav')).play();
3340
}
41+
notify();
3442
return regex.replace(text, mask);
3543
}
3644

@@ -39,3 +47,41 @@ eventManager.on('ChatDetected', () => {
3947
return original;
4048
});
4149
});
50+
51+
function notify() {
52+
if (disabled || notified) return;
53+
notified = true;
54+
const words = pingExtras.value();
55+
if (!words.includes('@underscript')) return;
56+
infoToast({
57+
text: 'UnderScript has custom notifications! You can change them however you like.',
58+
buttons: [{
59+
text: 'Open settings',
60+
className: 'dismiss',
61+
onclick() {
62+
pingExtras.show(true);
63+
},
64+
}, {
65+
text: 'Remove @underscript!',
66+
className: 'dismiss',
67+
onclick() {
68+
pingExtras.set(words.filter((word) => word !== '@underscript'));
69+
},
70+
}, {
71+
text: 'Dismiss',
72+
className: 'dismiss',
73+
}],
74+
className: 'dismissable',
75+
css: {
76+
button: {
77+
border: '',
78+
height: '',
79+
background: '',
80+
'font-size': '',
81+
margin: '',
82+
'border-radius': '',
83+
'white-space': 'normal',
84+
},
85+
},
86+
}, 'underscript.alert.ping');
87+
}

src/base/chat/toast.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const globalPing = settings.register({
2222
page: 'Chat',
2323
});
2424

25-
settings.register({
25+
export const pingExtras = settings.register({
2626
name: 'On',
2727
key: 'underscript.ping.extras',
2828
type: 'array',

src/base/styles/toast.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1+
import css from '../../utils/css.js';
12
import style from '../../utils/style.js';
23

3-
style.add(
4-
'#AlertToast { height: 0; }',
5-
'#AlertToast .dismissable > span { display: block; text-align: center; }',
6-
'#AlertToast .dismissable .dismiss { width: 160px; text-transform: capitalize; display: block; font-family: DTM-Mono; border: 1px solid #fff; font-size: 14px; margin: 5px auto; background-color: transparent; }',
7-
'#AlertToast .dismissable .dismiss:hover { opacity: 0.6; }',
8-
);
4+
style.add(css`
5+
#AlertToast {
6+
height: 0;
7+
}
8+
#AlertToast .dismissable > span {
9+
display: block;
10+
text-align: center;
11+
}
12+
#AlertToast .dismissable .dismiss {
13+
background-color: transparent;
14+
border: 1px solid #fff;
15+
display: block;
16+
font-family: DTM-Mono;
17+
font-size: 14px;
18+
margin: 5px auto;
19+
max-width: 80%;
20+
min-width: 160px;
21+
text-transform: capitalize;
22+
}
23+
#AlertToast .dismissable .dismiss:hover {
24+
opacity: 0.6;
25+
}
26+
`);

src/utils/2.toasts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function errorToast(error) {
4949
return toast(lToast);
5050
}
5151

52-
export function infoToast(arg, key, val) {
52+
export function infoToast(arg, key, val = '1') {
5353
if (localStorage.getItem(key) === val) return null;
5454
if (typeof arg === 'string') {
5555
arg = {

0 commit comments

Comments
 (0)