33// @description Speaks new question titles aloud as they come in
44// @author CertainPerformance
55// @namespace https://github.com/CertainPerformance/Stack-Exchange-Userscripts
6- // @version 1.0.4
6+ // @version 1.0.5
77// @include /^https://(?:[^/]+\.)?(?:(?:stackoverflow|serverfault|superuser|stackexchange|askubuntu|stackapps)\.com|mathoverflow\.net)/questions(?:/\d+|$|\?tab=Newest$|/tagged/.*sort=newest)/
88// @include /^https://example\.com/fakepage$/
99// @grant none
@@ -246,6 +246,7 @@ const watchedTags = ((_a = document.querySelector('#search input')) === null ||
246246const questionTagCountsLeftById = { } ;
247247const siteName = window . location . href === 'https://example.com/fakepage' ? '' : window . StackExchange . options . site . name ;
248248const siteNameSpokenText = siteName === 'Stack Overflow' ? '' : `${ siteName } , ` ;
249+ const tagSelector = '.post-tag' ;
249250exports . checkNewQuestions = ( ) => {
250251 temporarilyPreventClicks_1 . temporarilyPreventClicks ( ) ;
251252 for ( const questionDiv of getQuestionDivs ( ) ) {
@@ -272,7 +273,7 @@ exports.checkNewQuestions = () => {
272273 * Only on that nth time does the code below result in the questionDiv actually getting changed, watched, and linked to the utterance that gets queued
273274 */
274275 if ( ! questionTagCountsLeftById . hasOwnProperty ( questionId ) ) {
275- const watchedTagCountForThisQuestion = Array . from ( questionDiv . querySelectorAll ( '.tags > a' ) , a => a . textContent )
276+ const watchedTagCountForThisQuestion = Array . from ( questionDiv . querySelectorAll ( tagSelector ) , a => a . textContent )
276277 . reduce ( ( a , tag ) => a + Number ( watchedTags . includes ( tag ) ) , 0 ) ;
277278 questionTagCountsLeftById [ questionId ] = watchedTagCountForThisQuestion ;
278279 }
@@ -288,7 +289,7 @@ exports.checkNewQuestions = () => {
288289 continue ;
289290 }
290291 const questionText = questionDiv . querySelector ( '.question-hyperlink' ) . textContent ;
291- const questionTags = [ ...questionDiv . querySelectorAll ( '.tags > a' ) ]
292+ const questionTags = [ ...questionDiv . querySelectorAll ( tagSelector ) ]
292293 . map ( tagA => tagA . textContent . replace ( / \. / g, ' dot ' ) ) ;
293294 const textToSpeak = `Question, ${ siteNameSpokenText } ${ questionText } ---- ${ questionTags . join ( ', ' ) } ` ;
294295 queueUtterance_1 . queueUtterance ( textToSpeak , questionId ) ;
0 commit comments