Skip to content

Commit 1ef160b

Browse files
authored
Merge pull request #43 from koudaiii/koudaiii/fix-does-not-work
Switched from the data-article-date Element to Using the local-time Tag
2 parents a9c30d8 + 63ab630 commit 1ef160b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/content.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const timeAgoLabels = {
3636

3737
const debug = new URLSearchParams(window.location.search).get("jp-learn-microsoft-com-update-checker-debug");
3838

39-
// Get data-article-date element in current page
40-
const dataArticleDateElement = document.querySelector('time[data-article-date]');
39+
// Get local-time tag in current page
40+
const dataArticleDateElement = document.querySelector('local-time');
4141
if (!dataArticleDateElement) return;
4242

4343
// Parse article date
@@ -56,7 +56,7 @@ const timeAgoLabels = {
5656
const parser = new DOMParser();
5757
const doc = parser.parseFromString(data, "text/html");
5858

59-
const englishDateStr = doc.querySelector('time[data-article-date]')?.getAttribute("datetime");
59+
const englishDateStr = doc.querySelector('local-time')?.getAttribute("datetime");
6060
if (!englishDateStr) return;
6161
const englishDate = new Date(englishDateStr);
6262

tests/e2e/content.e2e.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ describe('learn.microsoft.com Update Checker E2E Test', () => {
100100
}, testCase.themeColor);
101101
await page.waitForSelector('button[aria-pressed="true"]');
102102

103-
// Wait for the time element with the 'data-article-date' attribute to be added
104-
await page.waitForSelector('time[data-article-date]');
103+
// Wait for the time element with the 'local-time' attribute to be added
104+
await page.waitForSelector('local-time');
105105

106106
const englishDateText = await page.evaluate((expectedText) => {
107107
return new Promise(resolve => setTimeout(resolve, 1000)) // Add a delay to allow time for the element to be added

0 commit comments

Comments
 (0)