Created
May 8, 2024 06:59
-
-
Save kane-c/c812e42be4accb0ff1db92562f6d5bf2 to your computer and use it in GitHub Desktop.
UserScript: Premii Hacker News improvements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Premii Hacker News improvements | |
// @namespace github.com/kane-c | |
// @version 1.0.0 | |
// @description Enhance hn.premii.com | |
// @author @kane-c | |
// @match https://hn.premii.com/ | |
// @icon https://hn.premii.com/a/icon/hn/Icon-32.png | |
// @grant none | |
// @updateURL https://gist.github.com/kane-c/c812e42be4accb0ff1db92562f6d5bf2/raw/2196f413be8abdd3793c2ab5adef715d7ca5dea5/premii.user.js | |
// @downloadURL https://gist.github.com/kane-c/c812e42be4accb0ff1db92562f6d5bf2/raw/2196f413be8abdd3793c2ab5adef715d7ca5dea5/premii.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function updateTitle() { | |
const { hash } = window.location; | |
let title; | |
if (hash.startsWith('#/comments/')) { | |
const h3 = document.querySelector('h3.title'); | |
if (!h3) { | |
title = 'Hacker News'; | |
} else { | |
title = h3.innerText; | |
title += ' | Hacker News'; | |
} | |
} else { | |
title = 'Hacker News'; | |
} | |
document.title = title; | |
} | |
window.addEventListener('hashchange', updateTitle); | |
updateTitle(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment