Skip to content

Commit

Permalink
DRY up redirection of home page to archive
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonAlling committed Jul 18, 2024
1 parent 8b7acfb commit 421025c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/operations/redirect-home-page-to-archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ export default (e: {
if (document.location.pathname === "/") {
document.location.pathname = SITE.PATH.ARCHIVE;
} else {
// Yes, this is repetitive. Yes, `Object.values` exists. But no, Userscripter (as of version 2.0.0) creates `e` with `Object.defineProperty` without the `enumerable` flag enabled, so `Object.values` returns the empty array.
(e.headerLogoLink as HTMLAnchorElement).href = SITE.PATH.ARCHIVE;
(e.latestNewsWidgetLink as HTMLAnchorElement).href = SITE.PATH.ARCHIVE;
(e.footerLogoLink as HTMLAnchorElement).href = SITE.PATH.ARCHIVE;
for (const link of Object.values(e)) {
(link as HTMLAnchorElement).href = SITE.PATH.ARCHIVE;
}
}
};

0 comments on commit 421025c

Please sign in to comment.