import { showToastError } from '../../../common/showToast' ; import { fixCommentTab } from './fixCommentTab' ; import { styleTag } from './styleTag' ; export const watchForCommentTab = ( ) => { const mainBarFull = document . querySelector ( '#mainbar-full' ) ! ; const onMutation = ( ) => { const commentTabHighlighted = document . querySelector < HTMLAnchorElement > ( '#user-tab-activity .is-selected' ) ! . href . endsWith ( '&sort=comments' ) ; if ( ! commentTabHighlighted ) { styleTag . remove ( ) ; return ; } document . body . appendChild ( styleTag ) ; fixCommentTab ( ) . catch ( ( error ) => { console . error ( error ) ; showToastError ( 'Stack Comment History Checker: An error occurred, see console for details' ) ; } ) ; } ; new MutationObserver ( onMutation ) . observe ( mainBarFull , { childList : true } ) ; window . StackExchange . ready ( onMutation ) ; } ;