@@ -104,7 +104,7 @@ function options(open) {
104104 userOptions . scrollPosition =
105105 document . getElementById ( "option_scrollPosition" ) . value ;
106106
107- userOptions . expandOption =
107+ userOptions . expandOption =
108108 document . getElementById ( "option_expandOption" ) . value ;
109109
110110 userOptions . backgroundHex =
@@ -519,6 +519,9 @@ document.getElementById("LKresetoptions").addEventListener("click", (e) => {
519519 localStorage . clear ( ) ;
520520 window . location . reload ( ) ;
521521} ) ;
522+ document . getElementById ( "navTitle" ) . addEventListener ( "click" , ( ) => {
523+ sessionStorage . setItem ( 'currentselection' , 0 ) ;
524+ } ) ;
522525
523526// Global variables
524527let currentEntry ;
@@ -955,7 +958,12 @@ function selectEntry(e, scrollIntoView = false) {
955958 }
956959 }
957960 currentEntry = e ;
958- currentEntry . classList . add ( selectedClass ) ;
961+ try {
962+ currentEntry . classList . add ( selectedClass ) ;
963+ } catch { // if currentEntry is undefined
964+ currentEntry = document . querySelectorAll ( ".post-listing, .comment-node" ) [ 0 ] ;
965+ currentEntry . classList . add ( selectedClass ) ;
966+ }
959967 sessionCurrentEntry ( "save" ) ;
960968 let links = currentEntry . getElementsByClassName ( "md-div" ) [ 0 ] ;
961969 if ( links ) {
@@ -1147,8 +1155,14 @@ function instanceAndUser(n) {
11471155var selectionType ;
11481156function checkSelection ( ) {
11491157 let postSelection = document . getElementsByClassName ( "post-listing mt-2 selected" ) [ 0 ] ;
1150- let username = '@' + document . getElementsByClassName ( "btn dropdown-toggle" ) [ 0 ] . textContent ;
1158+ let username ;
1159+ try {
1160+ username = '@' + document . getElementsByClassName ( "btn dropdown-toggle" ) [ 0 ] . textContent ;
1161+ } catch {
1162+ username = '' ; // logged out
1163+ }
11511164 let posterusername = currentEntry . getElementsByClassName ( "person-listing d-inline-flex align-items-baseline text-info" ) [ 0 ] . innerText ;
1165+ let contextCheck ;
11521166
11531167 if ( postSelection ) {
11541168 selectionType = "post" ;
@@ -1158,11 +1172,11 @@ function checkSelection() {
11581172 }
11591173
11601174 if ( window . location . pathname . includes ( "/post/" ) ) {
1161- contextCheck = currentEntry . getElementsByClassName ( "btn btn-link btn-animate" ) [ 13 ] ; // check for direct link button
1162- if ( contextCheck ) {
1163- selectionType = "post-page-fedi"
1164- } else {
1175+ contextCheck = currentEntry . getElementsByClassName ( "btn btn-link btn-animate" ) [ 8 ] . href ; // check for direct link button
1176+ if ( contextCheck === `${ window . location . origin } /create_post` ) {
11651177 selectionType = "post-page"
1178+ } else {
1179+ selectionType = "post-page-fedi"
11661180 }
11671181 }
11681182 } else {
0 commit comments