Skip to content

Commit

Permalink
Fix new HN time format breaking Newest Items
Browse files Browse the repository at this point in the history
  • Loading branch information
qsantos committed Oct 23, 2024
1 parent 87d99e6 commit cef5a5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v1.28

- Handle new time format in Hacker News that breaks Newest Items

# v1.27

- Immediately scroll to corresponding item when navigating newest items #54
Expand Down
7 changes: 4 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,10 @@ chrome.storage.sync.get((options) => {
parts.push("<ul>");
let lastDay = null;
for (const [datetime, index] of datedIndexes) {
// for format provided by Hacker News is "2024-09-03T19:06:26.000000Z"
const [day, rest] = datetime.split("T");
const [time, fraction] = rest.split(".");
// for format provided by Hacker News is "2024-09-03T19:06:26 000000"
// slice should be slightly more robust to change than split
const day = datetime.slice(0, 10);
const time = datetime.slice(11, 19);
if (day === lastDay) {
parts.push(
`<li data-index="${index}">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ${time}</li>`,
Expand Down

0 comments on commit cef5a5b

Please sign in to comment.