@@ -59,20 +59,26 @@ <h4 class="card-header">
5959 />
6060 < label for ="instance-filter-dropdown "> Found Instances:</ label >
6161 < select id ="instance-filter-dropdown ">
62- < option value =""> </ option >
62+ < option value =""> All Instances </ option >
6363 </ select >
6464 </ div >
6565 </ div >
6666 < div class ="row ">
6767 < div class ="col-sm-10 ">
68- < label for ="blacklist-ids-incoming " style ="width: 80px "
69- > Blacklist Methods</ label
68+ < div style ="display: inline-block; margin-right: 10px; ">
69+ < select id ="filter-mode " style ="padding: 3px; ">
70+ < option value ="blacklist "> Blacklist</ option >
71+ < option value ="whitelist "> Whitelist</ option >
72+ </ select >
73+ </ div >
74+ < label for ="method-filter-ids " id ="filter-label " style ="width: 80px "
75+ > Methods</ label
7076 >
7177 < input
7278 type ="text "
73- id ="blacklist-ids-incoming "
79+ id ="method-filter-ids "
7480 placeholder ="5026,1601,1103,... "
75- style ="width: calc(100% - 83px ) "
81+ style ="width: calc(100% - 200px ) "
7682 />
7783 </ div >
7884 < div class ="col-sm-2 ">
@@ -203,7 +209,8 @@ <h5 class="modal-title">
203209 let messages = [ ] ;
204210 let foundInstances = [ ] ;
205211 let instanceFilter = "" ;
206- let incomingBlacklistIds = [ ] ;
212+ let methodFilterIds = [ ] ;
213+ let filterMode = "blacklist" ;
207214 incoming . on ( "protos" , function ( data ) {
208215 if ( foundInstances . indexOf ( data . identifier ) === - 1 ) {
209216 foundInstances . push ( data . identifier ) ;
@@ -212,11 +219,16 @@ <h5 class="modal-title">
212219 if ( STATE !== 1 ) {
213220 return ;
214221 }
215- if ( instanceFilter == "" || data . identifier !== instanceFilter ) {
222+ if ( instanceFilter ! == "" && data . identifier !== instanceFilter ) {
216223 return ;
217224 }
218- if ( incomingBlacklistIds . length > 0 ) {
219- if ( incomingBlacklistIds . indexOf ( data . methodId ) !== - 1 ) {
225+ if ( methodFilterIds . length > 0 ) {
226+ const methodIdNum = parseInt ( data . methodId ) ;
227+ const isInList = methodFilterIds . indexOf ( methodIdNum ) !== - 1 ;
228+ if ( filterMode === "blacklist" && isInList ) {
229+ return ;
230+ }
231+ if ( filterMode === "whitelist" && ! isInList ) {
220232 return ;
221233 }
222234 }
@@ -260,12 +272,17 @@ <h5 class="modal-title">
260272 if ( STATE !== 1 ) {
261273 return ;
262274 }
263- if ( incomingBlacklistIds . length > 0 ) {
264- if ( incomingBlacklistIds . indexOf ( data . methodId ) !== - 1 ) {
275+ if ( methodFilterIds . length > 0 ) {
276+ const methodIdNum = parseInt ( data . methodId ) ;
277+ const isInList = methodFilterIds . indexOf ( methodIdNum ) !== - 1 ;
278+ if ( filterMode === "blacklist" && isInList ) {
279+ return ;
280+ }
281+ if ( filterMode === "whitelist" && ! isInList ) {
265282 return ;
266283 }
267284 }
268- if ( instanceFilter == "" || data . identifier !== instanceFilter ) {
285+ if ( instanceFilter ! == "" && data . identifier !== instanceFilter ) {
269286 return ;
270287 }
271288 if ( typeof data . error !== "undefined" ) {
@@ -456,8 +473,8 @@ <h5 class="modal-title">
456473 instanceFilter = $ ( this ) . val ( ) ;
457474 storeSettings ( ) ;
458475 } ) ;
459- $ ( "#blacklist-ids-incoming " ) . keyup ( function ( ) {
460- incomingBlacklistIds =
476+ $ ( "#method-filter-ids " ) . keyup ( function ( ) {
477+ methodFilterIds =
461478 $ ( this ) . val ( ) === ""
462479 ? [ ]
463480 : $ ( this )
@@ -466,6 +483,12 @@ <h5 class="modal-title">
466483 . map ( ( x ) => parseInt ( x ) ) ;
467484 storeSettings ( ) ;
468485 } ) ;
486+
487+ $ ( "#filter-mode" ) . change ( function ( ) {
488+ filterMode = $ ( this ) . val ( ) ;
489+ clearTable ( ) ;
490+ storeSettings ( ) ;
491+ } ) ;
469492 $ ( "#maxlogs" ) . on ( "change" , function ( ) {
470493 if ( this . value == "Other" ) {
471494 let val = prompt ( "Please enter the value" , "" ) ;
@@ -482,8 +505,16 @@ <h5 class="modal-title">
482505 if ( settingsJson !== null ) {
483506 const settings = JSON . parse ( settingsJson ) ;
484507 ( STATE = parseInt ( settings [ "STATE" ] ) ) ,
485- ( instanceFilter = settings [ "instanceFilter" ] ) ,
486- ( incomingBlacklistIds = settings [ "incomingBlacklistIds" ] ) ;
508+ ( instanceFilter = settings [ "instanceFilter" ] ) ;
509+ // Handle legacy blacklist settings
510+ if ( settings [ "incomingBlacklistIds" ] ) {
511+ methodFilterIds = settings [ "incomingBlacklistIds" ] ;
512+ } else if ( settings [ "methodFilterIds" ] ) {
513+ methodFilterIds = settings [ "methodFilterIds" ] ;
514+ }
515+ if ( settings [ "filterMode" ] ) {
516+ filterMode = settings [ "filterMode" ] ;
517+ }
487518 if ( settings [ "maxLogs" ] != null && ! isNaN ( parseInt ( maxLogs ) ) ) {
488519 setLogValue ( parseInt ( settings [ "maxLogs" ] ) ) ;
489520 }
@@ -495,7 +526,8 @@ <h5 class="modal-title">
495526 $ ( "#play-button" ) . click ( ) ;
496527 }
497528 $ ( "#instance-filter" ) . val ( instanceFilter ) ;
498- $ ( "#blacklist-ids-incoming" ) . val ( incomingBlacklistIds . join ( "," ) ) ;
529+ $ ( "#method-filter-ids" ) . val ( methodFilterIds . join ( "," ) ) ;
530+ $ ( "#filter-mode" ) . val ( filterMode ) ;
499531 }
500532 $ ( "#maxlogs" ) . val ( maxLogs ) ;
501533 }
@@ -506,7 +538,8 @@ <h5 class="modal-title">
506538 JSON . stringify ( {
507539 STATE : STATE ,
508540 instanceFilter : instanceFilter ,
509- incomingBlacklistIds : incomingBlacklistIds ,
541+ methodFilterIds : methodFilterIds ,
542+ filterMode : filterMode ,
510543 maxLogs : maxLogs ,
511544 darkMode : darkMode
512545 } )
0 commit comments