23082308 .context-menu__item : hover > * {
23092309 color : # fff !important ;
23102310 }
2311- .context-menu__item : hover {
2312- color : # fff !important ;
2313- background-color : # 0066aa !important ;
2314- }
2315- .context-menu__tip {
2316- margin-left : 15px ;
2317- color : # 777 ;
2311+ .context-menu__item : hover {
2312+ color : # fff !important ;
2313+ background-color : # 0066aa !important ;
2314+ }
2315+ .context-menu__item--warn > .context-menu__link {
2316+ color : # 8a5a00 ;
2317+ }
2318+ .context-menu__tip {
2319+ margin-left : 15px ;
2320+ color : # 777 ;
23182321 margin-top : 10px ;
23192322 padding-top : 10px ;
2320- position : relative;
2321- top : 7px ;
2322- }
2323- .hideMenuKeepScrollLock {
2323+ position : relative;
2324+ top : 7px ;
2325+ }
2326+ # dockActionNotice {
2327+ position : fixed;
2328+ left : 50% ;
2329+ top : 18px ;
2330+ transform : translateX (-50% );
2331+ z-index : 99999 ;
2332+ max-width : min (520px , calc (100vw - 32px ));
2333+ padding : 10px 14px ;
2334+ border-radius : 6px ;
2335+ background : rgba (20 , 20 , 20 , 0.92 );
2336+ color : # fff ;
2337+ font-family : Arial, sans-serif;
2338+ font-size : 14px ;
2339+ line-height : 1.35 ;
2340+ text-align : center;
2341+ box-shadow : 0 4px 18px rgba (0 , 0 , 0 , 0.28 );
2342+ }
2343+ .hideMenuKeepScrollLock {
23242344 height : 0 !important ;
23252345 border : 0 !important ;
23262346 box-shadow : unset !important ;
@@ -5157,11 +5177,10 @@ <h3>Status</h3>
51575177 document . querySelector ( '[data-action="Delete"] span' ) . innerText = "Delete Message (locally only)" ;
51585178 document . querySelector ( '[data-action="Delete"]' ) . title = "Using chat/view-only mode disables the ability to syncronize deleted messages with other docks" ;
51595179 }
5160- if ( blockMessageSelecting2 || blockMessageSelecting ) {
5161- document . querySelector ( '[data-action="Block"]' ) . classList . add ( "hidden" ) ;
5162- document . querySelector ( '[data-action="Timeout"]' ) . classList . add ( "hidden" ) ;
5180+ if ( blockMessageSelecting2 || blockMessageSelecting ) {
5181+ document . querySelector ( '[data-action="Timeout"]' ) . classList . add ( "hidden" ) ;
51635182 document . querySelector ( '[data-action="MarkHost"]' ) . classList . add ( "hidden" ) ;
5164- document . querySelector ( '[data-action="MarkMod"]' ) . classList . add ( "hidden" ) ;
5183+ document . querySelector ( '[data-action="MarkMod"]' ) . classList . add ( "hidden" ) ;
51655184 document . querySelector ( '[data-action="MarkBot"]' ) . classList . add ( "hidden" ) ;
51665185 }
51675186 } catch ( e ) { }
@@ -6950,39 +6969,18 @@ <h2 id="messagesFor">Messages</h2>\
69506969 ele . remove ( ) ;
69516970 } ) ;
69526971
6953- if ( data . blockUser . type == "youtube" ) {
6954- if ( ! localBlockUserList [ blockName ] . includes ( "youtubeshorts" ) ) {
6955- localBlockUserList [ blockName ] . push ( "youtubeshorts" ) ;
6956- }
6957- document . querySelectorAll ( "[data-chatname='" + blockName + "'][data-source-type='youtubeshorts']" ) . forEach ( ele => {
6958- ele . remove ( ) ;
6959- } ) ;
6960- }
6961-
6962- // Remove user from local block list after 10 seconds
6963- setTimeout ( ( ) => {
6964- if ( localBlockUserList && localBlockUserList [ blockName ] ) {
6965- const typeIndex = localBlockUserList [ blockName ] . indexOf ( data . blockUser . type ) ;
6966- if ( typeIndex !== - 1 ) {
6967- localBlockUserList [ blockName ] . splice ( typeIndex , 1 ) ;
6968- }
6969-
6970- if ( data . blockUser . type == "youtube" ) {
6971- const shortsIndex = localBlockUserList [ blockName ] . indexOf ( "youtubeshorts" ) ;
6972- if ( shortsIndex !== - 1 ) {
6973- localBlockUserList [ blockName ] . splice ( shortsIndex , 1 ) ;
6974- }
6975- }
6976-
6977- if ( localBlockUserList [ blockName ] . length === 0 ) {
6978- delete localBlockUserList [ blockName ] ;
6979- }
6980- }
6981- } , 10000 ) ;
6982-
6983- } else if ( data . blockUser . username ) {
6984- if ( ! localBlockUserList ) {
6985- localBlockUserList = { } ;
6972+ if ( data . blockUser . type == "youtube" ) {
6973+ if ( ! localBlockUserList [ blockName ] . includes ( "youtubeshorts" ) ) {
6974+ localBlockUserList [ blockName ] . push ( "youtubeshorts" ) ;
6975+ }
6976+ document . querySelectorAll ( "[data-chatname='" + blockName + "'][data-source-type='youtubeshorts']" ) . forEach ( ele => {
6977+ ele . remove ( ) ;
6978+ } ) ;
6979+ }
6980+
6981+ } else if ( data . blockUser . username ) {
6982+ if ( ! localBlockUserList ) {
6983+ localBlockUserList = { } ;
69866984 }
69876985 if ( localBlockUserList [ data . blockUser . username ] ) {
69886986 if ( ! localBlockUserList [ data . blockUser . username ] . includes ( "*" ) ) {
@@ -6991,23 +6989,10 @@ <h2 id="messagesFor">Messages</h2>\
69916989 } else {
69926990 localBlockUserList [ data . blockUser . username ] = [ "*" ] ;
69936991 }
6994- document . querySelectorAll ( "[data-chatname='" + data . blockUser . username + "']" ) . forEach ( ele => {
6995- ele . remove ( ) ;
6996- } ) ;
6997-
6998- // Remove user from local block list after 10 seconds
6999- setTimeout ( ( ) => {
7000- if ( localBlockUserList && localBlockUserList [ data . blockUser . username ] ) {
7001- const index = localBlockUserList [ data . blockUser . username ] . indexOf ( "*" ) ;
7002- if ( index !== - 1 ) {
7003- localBlockUserList [ data . blockUser . username ] . splice ( index , 1 ) ;
7004- if ( localBlockUserList [ data . blockUser . username ] . length === 0 ) {
7005- delete localBlockUserList [ data . blockUser . username ] ;
7006- }
7007- }
7008- }
7009- } , 10000 ) ;
7010- }
6992+ document . querySelectorAll ( "[data-chatname='" + data . blockUser . username + "']" ) . forEach ( ele => {
6993+ ele . remove ( ) ;
6994+ } ) ;
6995+ }
70116996 return true ;
70126997 } catch ( e ) {
70136998 console . error ( e ) ;
@@ -8274,25 +8259,88 @@ <h2 id="messagesFor">Messages</h2>\
82748259 return payload ;
82758260 }
82768261
8277- function deleteMessage ( element ) {
8278- syncDataAny ( { deleteMessage : element . dataset . mid } , false , true ) ;
8279- try {
8280- const payload = buildSourceControlPayload ( element ) ;
8281- if ( payload ) {
8262+ function deleteMessage ( element ) {
8263+ syncDataAny ( { deleteMessage : element . dataset . mid } , false , true ) ;
8264+ try {
8265+ const payload = buildSourceControlPayload ( element ) ;
8266+ if ( payload ) {
82828267 send2Extension ( { action : "deleteSourceMessage" , value : payload } ) ;
82838268 }
82848269 } catch ( e ) {
82858270 console . error ( e ) ;
8286- }
8287- element . remove ( ) ;
8288- }
8289-
8290- var localBlockUserList = false ;
8291- function blockUser ( element ) {
8292- try {
8293- var chatName = element . dataset . chatname ;
8294- var chatImg = element . dataset . chatimg || "" ;
8295- var type = element . dataset . sourceType ;
8271+ }
8272+ element . remove ( ) ;
8273+ }
8274+
8275+ var dockActionNoticeTimer = null ;
8276+ function showDockActionNotice ( message ) {
8277+ var notice = document . getElementById ( "dockActionNotice" ) ;
8278+ if ( ! notice ) {
8279+ notice = document . createElement ( "div" ) ;
8280+ notice . id = "dockActionNotice" ;
8281+ document . body . appendChild ( notice ) ;
8282+ }
8283+ notice . textContent = message ;
8284+ notice . style . display = "block" ;
8285+ clearTimeout ( dockActionNoticeTimer ) ;
8286+ dockActionNoticeTimer = setTimeout ( function ( ) {
8287+ notice . style . display = "none" ;
8288+ } , 4500 ) ;
8289+ }
8290+
8291+ function hasSocialStreamCommandPeer ( ) {
8292+ for ( var i = 0 ; i < iframes . length ; i ++ ) {
8293+ var iframe = iframes [ i ] ;
8294+ if ( ! iframe || ! iframe . connectedPeers ) {
8295+ continue ;
8296+ }
8297+ var keys = Object . keys ( iframe . connectedPeers ) ;
8298+ for ( var j = 0 ; j < keys . length ; j ++ ) {
8299+ if ( iframe . connectedPeers [ keys [ j ] ] === "SocialStream" ) {
8300+ return true ;
8301+ }
8302+ }
8303+ }
8304+ return false ;
8305+ }
8306+
8307+ function getBlockUserUnavailableReason ( ) {
8308+ if ( blockMessageSelecting ) {
8309+ return "Blocked locally only. View-only mode cannot save blocked users to the extension." ;
8310+ }
8311+ if ( blockMessageSelecting3 ) {
8312+ return "Blocked locally only. Helper mode cannot save blocked users to the extension." ;
8313+ }
8314+ if ( server3 && socketserverExtension && socketserverExtension . readyState === 1 ) {
8315+ return "" ;
8316+ }
8317+ if ( hasSocialStreamCommandPeer ( ) ) {
8318+ return "" ;
8319+ }
8320+ return "Blocked locally only. Dock cannot reach the extension yet, so this will reset on refresh." ;
8321+ }
8322+
8323+ function updateBlockUserMenuState ( ) {
8324+ var blockItem = document . querySelector ( '[data-action="Block"]' ) ;
8325+ if ( ! blockItem ) {
8326+ return ;
8327+ }
8328+ var reason = getBlockUserUnavailableReason ( ) ;
8329+ blockItem . title = reason || "All messages from user will be deleted; user will also get added to the hide-user list" ;
8330+ if ( reason ) {
8331+ blockItem . classList . add ( "context-menu__item--warn" ) ;
8332+ } else {
8333+ blockItem . classList . remove ( "context-menu__item--warn" ) ;
8334+ }
8335+ }
8336+
8337+ var localBlockUserList = false ;
8338+ function blockUser ( element ) {
8339+ try {
8340+ var blockUnavailableReason = getBlockUserUnavailableReason ( ) ;
8341+ var chatName = element . dataset . chatname ;
8342+ var chatImg = element . dataset . chatimg || "" ;
8343+ var type = element . dataset . sourceType ;
82968344
82978345 //console.log(chatName, type);
82988346
@@ -8325,26 +8373,17 @@ <h2 id="messagesFor">Messages</h2>\
83258373 if ( chatImg ) {
83268374 sendBlob . chatimg = chatImg ;
83278375 }
8328-
8329- //console.log(sendBlob);
8330-
8331- send2Extension ( { action : "blockUser" , value : sendBlob } ) ;
8332-
8333- // Remove user from local block list after 10 seconds
8334- setTimeout ( ( ) => {
8335- if ( localBlockUserList && localBlockUserList [ chatName ] ) {
8336- const index = localBlockUserList [ chatName ] . indexOf ( type ) ;
8337- if ( index !== - 1 ) {
8338- localBlockUserList [ chatName ] . splice ( index , 1 ) ;
8339- if ( localBlockUserList [ chatName ] . length === 0 ) {
8340- delete localBlockUserList [ chatName ] ;
8341- }
8342- }
8343- }
8344- } , 10000 ) ;
8345- }
8346- } catch ( e ) {
8347- console . error ( e ) ;
8376+
8377+ //console.log(sendBlob);
8378+
8379+ if ( blockUnavailableReason ) {
8380+ showDockActionNotice ( blockUnavailableReason ) ;
8381+ } else {
8382+ send2Extension ( { action : "blockUser" , value : sendBlob } ) ;
8383+ }
8384+ }
8385+ } catch ( e ) {
8386+ console . error ( e ) ;
83488387 }
83498388 }
83508389
@@ -11319,11 +11358,12 @@ <h2 id="messagesFor">Messages</h2>\
1131911358 }
1132011359 }
1132111360
11322- function toggleMenuOn ( ) {
11323- if ( menuState !== 1 ) {
11324- menuState = 1 ;
11325- menu . classList . add ( "context-menu--active" ) ;
11326- document . addEventListener ( "click" , menuClickListener ) ;
11361+ function toggleMenuOn ( ) {
11362+ if ( menuState !== 1 ) {
11363+ updateBlockUserMenuState ( ) ;
11364+ menuState = 1 ;
11365+ menu . classList . add ( "context-menu--active" ) ;
11366+ document . addEventListener ( "click" , menuClickListener ) ;
1132711367
1132811368 const scale = Math . min ( 1 , window . innerHeight / menu . scrollHeight ) ;
1132911369 if ( scale ) {
0 commit comments