import { makeSpeakInterface } from './makeSpeakInterface' ; import { showSpeechSynthesisReadyness } from './showSpeechSynthesisReadyness' ; import { speakOnNewMessage } from './speakOnNewMessage' ; import { targetBlankAllAnchors } from './targetBlankAllAnchors' ; import { watchNewQuestions } from './watchNewQuestions' ; import { hideNewPostActivity } from './hideNewPostActivity' ; import { setupBroadcastChannelForFocusOnQuestionList } from './setupBroadcastChannelForFocusOnQuestionList' ; import { addBorderWhenClicked } from './addBorderWhenClicked' ; import { clearInterfaceOnDuplicatePageload } from './clearInterfaceOnDuplicatePageload' ; export const handleQuestionListPage = ( ) => { if ( window . location . pathname === '/questions' && ! document . querySelector ( '.is-selected[href="/questions?tab=Newest"]' ) ) { return ; } const channel = new BroadcastChannel ( 'cpUserscriptSpeakNewQuestions' ) ; const speakInterface = makeSpeakInterface ( ) ; clearInterfaceOnDuplicatePageload ( channel , speakInterface ) ; const focusButton = speakInterface . querySelector ( 'button' ) ; if ( focusButton ) { setupBroadcastChannelForFocusOnQuestionList ( channel , focusButton ) ; } showSpeechSynthesisReadyness ( ) ; speakOnNewMessage ( ) ; watchNewQuestions ( channel , speakInterface ) ; targetBlankAllAnchors ( document . body ) ; for ( const questionDiv of document . querySelectorAll < HTMLElement > ( '#questions > .question-summary' ) ) { addBorderWhenClicked ( questionDiv ) ; } hideNewPostActivity ( ) ; speechSynthesis . cancel ( ) ; } ;