@@ -3,6 +3,8 @@ import * as settings from '../../utils/settings/index.js';
33import { global , globalSet } from '../../utils/global.js' ;
44import pendingIgnore from '../../utils/pendingIgnore.js' ;
55import pingRegex from '../../utils/pingRegex.js' ;
6+ import { pingExtras } from './toast.js' ;
7+ import { infoToast } from '../../utils/2.toasts.js' ;
68
79const setting = settings . register ( {
810 name : 'Disable Chat Ping <span style="color: yellow;">(highlighting)</span>' ,
@@ -13,11 +15,16 @@ const setting = settings.register({
1315const mask = '<span style="color: yellow;">$1</span>' ;
1416
1517let disabled = false ;
18+ let notified = false ;
1619
1720eventManager . 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+ }
0 commit comments