20
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
// SOFTWARE.
22
22
23
- const outputZalgo = document . getElementById ( "regex-output-zalgo" ) ;
24
- const outputEmojiValue = document . getElementById ( "emoji-range-value" ) ;
25
- const outputEmoji = document . getElementById ( "regex-output-emoji" ) ;
26
- const outputLinks = document . getElementById ( "regex-output-links" ) ;
27
- const outputInvit = document . getElementById ( "regex-output-invite-links" ) ;
28
- const outputInlin = document . getElementById ( "regex-output-inline-links" ) ;
29
- const outputHeadnValue = document . getElementById ( "headn-range-value" ) ;
30
- const outputHeadn = document . getElementById ( "regex-output-headn" ) ;
31
- const outputEmail = document . getElementById ( "regex-output-email" ) ;
32
-
33
- const copyZalgo = document . getElementById ( "copy-regex-zalgo" ) ;
34
- const copyEmoji = document . getElementById ( "copy-regex-emoji" ) ;
35
- const copyLinks = document . getElementById ( "copy-regex-links" ) ;
36
- const copyInvit = document . getElementById ( "copy-regex-invite-links" ) ;
37
- const copyInlin = document . getElementById ( "copy-regex-inline-links" ) ;
38
- const copyHeadn = document . getElementById ( "copy-regex-headn" ) ;
39
- const copyEmail = document . getElementById ( "copy-regex-email" ) ;
40
-
41
- const checkbox_acc = document . getElementById ( "filter-accents" ) ;
42
- const emoji_slider = document . getElementById ( "emoji-range" ) ;
43
- const headn_slider = document . getElementById ( "headn-range" ) ;
44
- const inc_nonclick = document . getElementById ( "include-nonclickable" ) ;
45
- const inc_3prtyinv = document . getElementById ( "include-3rdparty" ) ;
46
-
47
-
48
- function updateRegexZalgo ( ) {
49
- copyZalgo . innerText = "Copy"
50
- if ( checkbox_acc . checked ) {
51
- outputZalgo . innerText = "\\p{M}{1,}" ;
52
- } else {
53
- outputZalgo . innerText = "\\p{M}{3,}" ;
54
- } ;
55
- } ;
56
-
57
- copyZalgo . onclick = function ( ) {
58
- navigator . clipboard . writeText ( outputZalgo . innerText ) ;
59
- copyZalgo . innerText = "Copied!" ;
60
- setTimeout ( function ( ) {
61
- copyZalgo . innerText = "Copy"
62
- } , 5000 ) ;
63
- }
64
-
65
- checkbox_acc . onchange = updateRegexZalgo ;
66
- updateRegexZalgo ( ) ;
67
-
68
- function updateRegexEmoji ( ) {
69
- copyEmoji . innerText = "Copy" ;
70
- outputEmojiValue . innerText = emoji_slider . value ;
71
- if ( emoji_slider . value == 0 ) {
72
- outputEmoji . innerText = `<a?:[a-z_0-9]+:[0-9]+>|\\p{Extended_Pictographic}|[\\u{1F1E6}-\\u{1F1FF}]|[0-9#\\*]\\u{fe0f})` ;
73
- } else {
74
- outputEmoji . innerText = `d(?s)(?i)((<a?:[a-z_0-9]+:[0-9]+>|\\p{Extended_Pictographic}|[\\u{1F1E6}-\\u{1F1FF}]|[0-9#\\*]\\u{fe0f}).*){${ + emoji_slider . value + 1 } ,}` ;
75
- } ;
76
- } ;
77
-
78
- copyEmoji . onclick = function ( ) {
79
- navigator . clipboard . writeText ( outputEmoji . innerText ) ;
80
- copyEmoji . innerText = "Copied!" ;
81
- setTimeout ( function ( ) {
82
- copyEmoji . innerText = "Copy"
83
- } , 5000 ) ;
84
- }
85
-
86
- emoji_slider . onchange = updateRegexEmoji
87
- emoji_slider . oninput = updateRegexEmoji
88
- updateRegexEmoji ( )
89
-
90
- function updateRegexLinks ( ) {
91
- copyLinks . innerText = "Copy"
92
- if ( inc_nonclick . checked ) {
93
- outputLinks . innerText = "(?:https?://)?[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}" ;
94
- } else {
95
- outputLinks . innerText = "(?:https?://)[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}" ;
96
- } ;
97
- } ;
98
-
99
- copyLinks . onclick = function ( ) {
100
- navigator . clipboard . writeText ( outputLinks . innerText ) ;
101
- copyLinks . innerText = "Copied!" ;
102
- setTimeout ( function ( ) {
103
- copyLinks . innerText = "Copy"
104
- } , 5000 ) ;
105
- }
106
-
107
- inc_nonclick . onchange = updateRegexLinks ;
108
- updateRegexLinks ( ) ;
109
-
110
- function updateRegexInlin ( ) {
111
- copyInlin . innerText = "Copy"
112
- outputInlin . innerText = "\\[.*\\]\\(<?(?:https?://)?[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}.*>?\\)" ;
113
- } ;
114
-
115
- copyInlin . onclick = function ( ) {
116
- navigator . clipboard . writeText ( outputInlin . innerText ) ;
117
- copyInlin . innerText = "Copied!" ;
118
- setTimeout ( function ( ) {
119
- copyInlin . innerText = "Copy"
120
- } , 5000 ) ;
121
- }
23
+ const regex_types = [
24
+ {
25
+ name : "zalgo" ,
26
+ copy_btn : document . getElementById ( "copy-regex-zalgo" ) ,
27
+ output : document . getElementById ( "regex-output-zalgo" ) ,
28
+ generator : function ( settings ) {
29
+ if ( settings . accents . checked ) {
30
+ return "\\p{M}{1,}" ;
31
+ } else {
32
+ return "\\p{M}{3,}" ;
33
+ } ;
34
+ } ,
35
+ setting_elements : {
36
+ accents : document . getElementById ( "filter-accents" )
37
+ }
38
+ } ,
39
+ {
40
+ name : "emoji-spam" ,
41
+ copy_btn : document . getElementById ( "copy-regex-emoji" ) ,
42
+ output : document . getElementById ( "regex-output-emoji" ) ,
43
+ generator : function ( settings ) {
44
+ const slider_value = document . getElementById ( "emoji-range-value" ) ;
45
+ slider_value . innerText = settings . slider . value ;
46
+
47
+ if ( settings . slider . value == 0 ) {
48
+ return `<a?:[a-z_0-9]+:[0-9]+>|\\p{Extended_Pictographic}|[\\u{1F1E6}-\\u{1F1FF}]|[0-9#\\*]\\u{fe0f})` ;
49
+ } else {
50
+ return `d(?s)(?i)((<a?:[a-z_0-9]+:[0-9]+>|\\p{Extended_Pictographic}|[\\u{1F1E6}-\\u{1F1FF}]|[0-9#\\*]\\u{fe0f}).*){${ + settings . slider . value + 1 } ,}` ;
51
+ } ;
52
+ } ,
53
+ setting_elements : {
54
+ slider : document . getElementById ( "emoji-range" )
55
+ }
56
+ } ,
57
+ {
58
+ name : "links" ,
59
+ copy_btn : document . getElementById ( "copy-regex-links" ) ,
60
+ output : document . getElementById ( "regex-output-links" ) ,
61
+ generator : function ( settings ) {
62
+ if ( settings . nonclick . checked ) {
63
+ return `(?:https?://)?[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}` ;
64
+ } else {
65
+ return `(?:https?://)[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}` ;
66
+ } ;
67
+ } ,
68
+ setting_elements : {
69
+ nonclick : document . getElementById ( "include-nonclickable" )
70
+ }
71
+ } ,
72
+ {
73
+ name : "inline-links" ,
74
+ copy_btn : document . getElementById ( "copy-regex-inline-links" ) ,
75
+ output : document . getElementById ( "regex-output-inline-links" ) ,
76
+ generator : function ( settings ) {
77
+ return `\\[.*\\]\\(<?(?:https?://)?[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}.*>?\\)`
78
+ } ,
79
+ setting_elements : { }
80
+ } ,
81
+ {
82
+ name : "invite-links" ,
83
+ copy_btn : document . getElementById ( "copy-regex-invite-links" ) ,
84
+ output : document . getElementById ( "regex-output-invite-links" ) ,
85
+ generator : function ( settings ) {
86
+ if ( settings . third_party . checked ) {
87
+ return "(?:https?://)?(?:www.|ptb.|canary.)?(?:discord(?:app)?\\.(?:(?:com|gg)/(?:invite|servers)/[a-z0-9-_]+)|discord\\.gg/[a-z0-9-_]+)|(?:https?://)?(?:www\\.)?(?:dsc\\.gg|invite\\.gg+|discord\\.link|(?:discord\\.(gg|io|me|li|id))|disboard\\.org)/[a-z0-9-_/]+" ;
88
+ } else {
89
+ return `(?:https?://)?(?:www.|ptb.|canary.)?(?:discord(?:app)?\\.(?:(?:com|gg)/(?:invite|servers)/[a-z0-9-_]+)|discord\\.gg/[a-z0-9-_]+)` ;
90
+ } ;
91
+ } ,
92
+ setting_elements : {
93
+ third_party : document . getElementById ( "include-3rdparty" )
94
+ }
95
+ } ,
96
+ {
97
+ name : "invite-links" ,
98
+ copy_btn : document . getElementById ( "copy-regex-invite-links" ) ,
99
+ output : document . getElementById ( "regex-output-invite-links" ) ,
100
+ generator : function ( settings ) {
101
+ if ( settings . third_party . checked ) {
102
+ return "(?:https?://)?(?:www.|ptb.|canary.)?(?:discord(?:app)?\\.(?:(?:com|gg)/(?:invite|servers)/[a-z0-9-_]+)|discord\\.gg/[a-z0-9-_]+)|(?:https?://)?(?:www\\.)?(?:dsc\\.gg|invite\\.gg+|discord\\.link|(?:discord\\.(gg|io|me|li|id))|disboard\\.org)/[a-z0-9-_/]+" ;
103
+ } else {
104
+ return `(?:https?://)?(?:www.|ptb.|canary.)?(?:discord(?:app)?\\.(?:(?:com|gg)/(?:invite|servers)/[a-z0-9-_]+)|discord\\.gg/[a-z0-9-_]+)` ;
105
+ } ;
106
+ } ,
107
+ setting_elements : {
108
+ third_party : document . getElementById ( "include-3rdparty" )
109
+ }
110
+ } ,
111
+ {
112
+ name : "headings" ,
113
+ copy_btn : document . getElementById ( "copy-regex-headn" ) ,
114
+ output : document . getElementById ( "regex-output-headn" ) ,
115
+ generator : function ( settings ) {
116
+ const slider_value = document . getElementById ( "headn-range-value" ) ;
117
+ if ( settings . slider . value == 4 ) {
118
+ slider_value . innerText = "-" ;
119
+ } else {
120
+ slider_value . innerText = settings . slider . value ;
121
+ } ;
122
+
123
+ if ( settings . slider . value == 2 ) {
124
+ return `^#\\s.*$` ;
125
+ } else {
126
+ return `^#{1,${ settings . slider . value - 1 } }\\s.*$` ;
127
+ }
128
+ } ,
129
+ setting_elements : {
130
+ slider : document . getElementById ( "headn-range" )
131
+ }
132
+ } ,
133
+ {
134
+ name : "email-addresses" ,
135
+ copy_btn : document . getElementById ( "copy-regex-email" ) ,
136
+ output : document . getElementById ( "regex-output-email" ) ,
137
+ generator : function ( settings ) {
138
+ return `[a-z0-9_\\-\\.\\+]+@[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}`
139
+ } ,
140
+ setting_elements : { }
141
+ }
142
+ ] ;
122
143
123
- updateRegexInlin ( ) ;
144
+ for ( var i = 0 ; i < regex_types . length ; i ++ ) {
145
+ let regex = regex_types [ i ] ;
124
146
125
- function updateRegexInvit ( ) {
126
- copyInvit . innerText = "Copy"
127
- if ( inc_3prtyinv . checked ) {
128
- outputInvit . innerText = "(?:https?://)?(?:www.|ptb.|canary.)?(?:discord(?:app)?\.(?:(?:com|gg)/(?:invite|servers)/[a-z0-9-_]+)|discord\.gg/[a-z0-9-_]+)|(?:https?://)?(?:www\.)?(?:dsc\.gg|invite\.gg+|discord\.link|(?:discord\.(gg|io|me|li|id))|disboard\.org)/[a-z0-9-_/]+"
129
- } else {
130
- outputInvit . innerText = "(?:https?://)?(?:www.|ptb.|canary.)?(?:discord(?:app)?\\.(?:(?:com|gg)/(?:invite|servers)/[a-z0-9-_]+)|discord\\.gg/[a-z0-9-_]+)" ;
147
+ function update ( ) {
148
+ regex . copy_btn . innerText = "Copy" ;
149
+ regex . output . innerText = regex . generator ( regex . setting_elements ) ;
131
150
}
132
- } ;
133
-
134
- copyInvit . onclick = function ( ) {
135
- navigator . clipboard . writeText ( outputInvit . innerText ) ;
136
- copyInvit . innerText = "Copied!" ;
137
- setTimeout ( function ( ) {
138
- copyInvit . innerText = "Copy"
139
- } , 5000 ) ;
140
- }
141
151
142
- updateRegexInvit ( ) ;
143
- inc_3prtyinv . onchange = updateRegexInvit
152
+ let setting_keys = Object . keys ( regex . setting_elements ) ;
153
+ for ( var i1 = 0 ; i1 < setting_keys . length ; i1 ++ ) {
154
+ let element = regex . setting_elements [ setting_keys [ i1 ] ] ;
144
155
145
- function updateRegexHeadn ( ) {
146
- copyHeadn . innerText = "Copy" ;
147
- if ( headn_slider . value == 4 ) {
148
- outputHeadnValue . innerText = "-" ;
149
- } else {
150
- outputHeadnValue . innerText = headn_slider . value ;
156
+ element . onchange = update ;
157
+ element . oninput = update ;
151
158
} ;
152
- if ( headn_slider . value == 2 ) {
153
- outputHeadn . innerText = `^#\\s.*$` ;
154
- } else {
155
- outputHeadn . innerText = `^#{1,${ headn_slider . value - 1 } }\\s.*$` ;
159
+ update ( ) ;
160
+
161
+ regex . copy_btn . onclick = function ( ) {
162
+ navigator . clipboard . writeText ( regex . output . innerText ) ;
163
+ regex . copy_btn . innerText = "Copied!" ;
164
+ setTimeout ( function ( ) {
165
+ regex . copy_btn . innerText = "Copy"
166
+ } , 5000 ) ;
156
167
}
157
168
} ;
158
-
159
- copyHeadn . onclick = function ( ) {
160
- navigator . clipboard . writeText ( outputHeadn . innerText ) ;
161
- copyHeadn . innerText = "Copied!" ;
162
- setTimeout ( function ( ) {
163
- copyHeadn . innerText = "Copy"
164
- } , 5000 ) ;
165
- } ;
166
-
167
- headn_slider . onchange = updateRegexHeadn ;
168
- headn_slider . oninput = updateRegexHeadn ;
169
- updateRegexHeadn ( ) ;
170
-
171
- function updateRegexEmail ( ) {
172
- copyEmail . innerText = "Copy"
173
- outputEmail . innerText = "[a-z0-9_\\-\\.\\+]+@[a-z0-9_\\-\\.]*[a-z0-9_\\-]+\\.[a-z]{2,}" ;
174
- } ;
175
-
176
- copyEmail . onclick = function ( ) {
177
- navigator . clipboard . writeText ( outputEmail . innerText ) ;
178
- copyEmail . innerText = "Copied!" ;
179
- setTimeout ( function ( ) {
180
- copyEmail . innerText = "Copy"
181
- } , 5000 ) ;
182
- }
183
-
184
- updateRegexEmail ( ) ;
0 commit comments