Skip to content

Instantly share code, notes, and snippets.

@kane-c
Created May 8, 2024 06:59
Show Gist options
  • Save kane-c/c812e42be4accb0ff1db92562f6d5bf2 to your computer and use it in GitHub Desktop.
Save kane-c/c812e42be4accb0ff1db92562f6d5bf2 to your computer and use it in GitHub Desktop.
UserScript: Premii Hacker News improvements
// ==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