3
3
// @description Speaks new question titles aloud as they come in
4
4
// @author CertainPerformance
5
5
// @namespace https://github.com/CertainPerformance/Stack-Exchange-Userscripts
6
- // @version 1.0.4
6
+ // @version 1.0.5
7
7
// @include /^https://(?:[^/]+\.)?(?:(?:stackoverflow|serverfault|superuser|stackexchange|askubuntu|stackapps)\.com|mathoverflow\.net)/questions(?:/\d+|$|\?tab=Newest$|/tagged/.*sort=newest)/
8
8
// @include /^https://example\.com/fakepage$/
9
9
// @grant none
@@ -246,6 +246,7 @@ const watchedTags = ((_a = document.querySelector('#search input')) === null ||
246
246
const questionTagCountsLeftById = { } ;
247
247
const siteName = window . location . href === 'https://example.com/fakepage' ? '' : window . StackExchange . options . site . name ;
248
248
const siteNameSpokenText = siteName === 'Stack Overflow' ? '' : `${ siteName } , ` ;
249
+ const tagSelector = '.post-tag' ;
249
250
exports . checkNewQuestions = ( ) => {
250
251
temporarilyPreventClicks_1 . temporarilyPreventClicks ( ) ;
251
252
for ( const questionDiv of getQuestionDivs ( ) ) {
@@ -272,7 +273,7 @@ exports.checkNewQuestions = () => {
272
273
* 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
273
274
*/
274
275
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 )
276
277
. reduce ( ( a , tag ) => a + Number ( watchedTags . includes ( tag ) ) , 0 ) ;
277
278
questionTagCountsLeftById [ questionId ] = watchedTagCountForThisQuestion ;
278
279
}
@@ -288,7 +289,7 @@ exports.checkNewQuestions = () => {
288
289
continue ;
289
290
}
290
291
const questionText = questionDiv . querySelector ( '.question-hyperlink' ) . textContent ;
291
- const questionTags = [ ...questionDiv . querySelectorAll ( '.tags > a' ) ]
292
+ const questionTags = [ ...questionDiv . querySelectorAll ( tagSelector ) ]
292
293
. map ( tagA => tagA . textContent . replace ( / \. / g, ' dot ' ) ) ;
293
294
const textToSpeak = `Question, ${ siteNameSpokenText } ${ questionText } ---- ${ questionTags . join ( ', ' ) } ` ;
294
295
queueUtterance_1 . queueUtterance ( textToSpeak , questionId ) ;
0 commit comments