@@ -1020,6 +1020,99 @@ function updateSourceTypeList(type) {
10201020 ` ) . join ( '' ) ;
10211021}
10221022
1023+ // Blocked words tag system functions
1024+ function updateBlockedWordsList ( ) {
1025+ const input = document . getElementById ( 'blockedwordsInput' ) ;
1026+ const list = document . getElementById ( 'blockedwordsList' ) ;
1027+ if ( ! input || ! list ) return ;
1028+
1029+ const words = input . value . split ( ',' )
1030+ . map ( w => w . trim ( ) )
1031+ . filter ( w => w ) ;
1032+
1033+ list . innerHTML = words . map ( word => `
1034+ <div class="username-tag">
1035+ <span>${ escapeHtml ( word ) } </span>
1036+ <button class="remove-blockedword" data-word="${ escapeHtml ( word ) } ">×</button>
1037+ </div>
1038+ ` ) . join ( '' ) ;
1039+ }
1040+
1041+ function escapeHtml ( text ) {
1042+ const div = document . createElement ( 'div' ) ;
1043+ div . textContent = text ;
1044+ return div . innerHTML ;
1045+ }
1046+
1047+ function addBlockedWord ( word ) {
1048+ const input = document . getElementById ( 'blockedwordsInput' ) ;
1049+ if ( ! input || ! word ) return ;
1050+
1051+ const words = input . value . split ( ',' ) . map ( w => w . trim ( ) ) . filter ( w => w ) ;
1052+ const trimmedWord = word . trim ( ) ;
1053+
1054+ if ( trimmedWord && ! words . some ( w => w . toLowerCase ( ) === trimmedWord . toLowerCase ( ) ) ) {
1055+ words . push ( trimmedWord ) ;
1056+ input . value = words . join ( ', ' ) ;
1057+ updateBlockedWordsList ( ) ;
1058+ updateSettings ( input ) ;
1059+ }
1060+ }
1061+
1062+ function removeBlockedWord ( word ) {
1063+ const input = document . getElementById ( 'blockedwordsInput' ) ;
1064+ if ( ! input ) return ;
1065+
1066+ const words = input . value . split ( ',' ) . map ( w => w . trim ( ) ) . filter ( w => w ) ;
1067+ const index = words . findIndex ( w => w . toLowerCase ( ) === word . toLowerCase ( ) ) ;
1068+
1069+ if ( index > - 1 ) {
1070+ words . splice ( index , 1 ) ;
1071+ input . value = words . join ( ', ' ) ;
1072+ updateBlockedWordsList ( ) ;
1073+ updateSettings ( input ) ;
1074+ }
1075+ }
1076+
1077+ function setupBlockedWordsInput ( ) {
1078+ const list = document . getElementById ( 'blockedwordsList' ) ;
1079+ const addBtn = document . getElementById ( 'addBlockedWord' ) ;
1080+ const newWordInput = document . getElementById ( 'newBlockedWord' ) ;
1081+
1082+ if ( ! list || ! addBtn || ! newWordInput ) return ;
1083+
1084+ // Handle clicking remove button on tags
1085+ list . addEventListener ( 'click' , ( e ) => {
1086+ if ( e . target . classList . contains ( 'remove-blockedword' ) ) {
1087+ removeBlockedWord ( e . target . dataset . word ) ;
1088+ }
1089+ } ) ;
1090+
1091+ // Handle add button click
1092+ addBtn . addEventListener ( 'click' , ( ) => {
1093+ const word = newWordInput . value . trim ( ) ;
1094+ if ( word ) {
1095+ addBlockedWord ( word ) ;
1096+ newWordInput . value = '' ;
1097+ }
1098+ } ) ;
1099+
1100+ // Handle Enter key in input
1101+ newWordInput . addEventListener ( 'keypress' , ( e ) => {
1102+ if ( e . key === 'Enter' ) {
1103+ e . preventDefault ( ) ;
1104+ const word = newWordInput . value . trim ( ) ;
1105+ if ( word ) {
1106+ addBlockedWord ( word ) ;
1107+ newWordInput . value = '' ;
1108+ }
1109+ }
1110+ } ) ;
1111+
1112+ // Initialize the list from any existing value
1113+ updateBlockedWordsList ( ) ;
1114+ }
1115+
10231116// Function to setup source selection for a given input
10241117function setupSourceSelection ( inputId , isSettingBased = false ) {
10251118 const input = isSettingBased ?
@@ -2114,6 +2207,11 @@ function processObjectSetting(key, settingObj, sync, paramNums, response) { // A
21142207 if ( paramEle && paramEle . checked ) {
21152208 updateSettings ( paramEle , false , settingObj [ textParamKey ] ) ;
21162209 }
2210+
2211+ // Refresh blocked words tag list if this is the blockedwords input
2212+ if ( key === 'blockedwords' ) {
2213+ updateBlockedWordsList ( ) ;
2214+ }
21172215 }
21182216 }
21192217
@@ -5469,7 +5567,10 @@ document.addEventListener("DOMContentLoaded", async function(event) {
54695567
54705568 // Initialize ProfileManager after DOM is ready
54715569 ProfileManager . init ( ) ;
5472-
5570+
5571+ // Initialize blocked words tag input
5572+ setupBlockedWordsInput ( ) ;
5573+
54735574 // Add event listener for save profile button
54745575 const saveProfileBtn = document . querySelector ( 'button[data-action="saveProfile"]' ) ;
54755576 if ( saveProfileBtn ) {
0 commit comments