Skip to content

Commit c3d3b3d

Browse files
Fix SE DOM change
1 parent 33ef0ae commit c3d3b3d

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Speak-New-Questions/dist/StackSpeakNewQuestions.user.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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 ||
246246
const questionTagCountsLeftById = {};
247247
const siteName = window.location.href === 'https://example.com/fakepage' ? '' : window.StackExchange.options.site.name;
248248
const siteNameSpokenText = siteName === 'Stack Overflow' ? '' : `${siteName}, `;
249+
const tagSelector = '.post-tag';
249250
exports.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);

Speak-New-Questions/src/questionListPage/checkNewQuestions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const questionTagCountsLeftById: { [questionId: string]: number } = {};
1313
const siteName = window.location.href === 'https://example.com/fakepage' ? '' : window.StackExchange.options.site.name;
1414
const siteNameSpokenText = siteName === 'Stack Overflow' ? '' : `${siteName}, `;
1515

16+
const tagSelector = '.post-tag';
17+
1618
export const checkNewQuestions = () => {
1719
temporarilyPreventClicks();
1820
for (const questionDiv of getQuestionDivs()) {
@@ -41,7 +43,7 @@ export const checkNewQuestions = () => {
4143
*/
4244
if (!questionTagCountsLeftById.hasOwnProperty(questionId)) {
4345
const watchedTagCountForThisQuestion = Array.from(
44-
questionDiv.querySelectorAll('.tags > a'),
46+
questionDiv.querySelectorAll(tagSelector),
4547
a => a.textContent!,
4648
)
4749
.reduce((a, tag) => a + Number(watchedTags.includes(tag)), 0);
@@ -59,7 +61,7 @@ export const checkNewQuestions = () => {
5961
continue;
6062
}
6163
const questionText = questionDiv.querySelector('.question-hyperlink')!.textContent;
62-
const questionTags = [...questionDiv.querySelectorAll('.tags > a')]
64+
const questionTags = [...questionDiv.querySelectorAll(tagSelector)]
6365
.map(tagA => tagA.textContent!.replace(/\./g, ' dot '));
6466
const textToSpeak = `Question, ${siteNameSpokenText} ${questionText} ---- ${questionTags.join(', ')}`;
6567
queueUtterance(textToSpeak, questionId);

Speak-New-Questions/src/userscript-metadata-block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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

0 commit comments

Comments
 (0)