Skip to content

Instantly share code, notes, and snippets.

@Onurtag
Last active March 18, 2022 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Onurtag/9877ada3641c64bc84c47171a374adc1 to your computer and use it in GitHub Desktop.
Save Onurtag/9877ada3641c64bc84c47171a374adc1 to your computer and use it in GitHub Desktop.
Band-aid fix for the hidden "More" comment pages for HNES on Firefox
// ==UserScript==
// @name HNES more comment pages
// @namespace hnes.more.fix
// @version 1.0.0
// @description Fixes Hacker News Enhancement Suite comment pages for Firefox
// @author You
// @match https://news.ycombinator.com/item*
// @icon https://www.google.com/s2/favicons?domain=ycombinator.com
// @grant none
// @run-at document-start
// ==/UserScript==
let fetched = false;
let pageUrl = null;
//fetch the current page (again) and check for .morelink
fetch(document.location).then(function(response) {
response.text().then(function(text) {
fetched = true;
let matches = text.match(/a href='(.*?)' class='morelink'/);
if (matches) {
pageUrl = matches[1];
}
});
});
let startInterval = setInterval(() => {
//wait for fetch
if (fetched) {
let commentsNode = document.querySelector("#hnes-comments");
//wait for commentsnode
if (commentsNode) {
//clear interval whether page exists or not
clearInterval(startInterval);
//add page links
if (pageUrl) {
commentsNode.insertAdjacentHTML("beforeend", `<a href="${pageUrl}" style="font-weight: bold;font-size: 11pt;font-family: arial;margin: -2px 10px 8px 10px;display: block;">View more comments...</a>`);
commentsNode.insertAdjacentHTML("afterbegin", `<a href="${pageUrl}" style="font-weight: bold;font-size: 11pt;font-family: arial;margin: -2px 10px 8px 10px;display: block;">View more comments...</a>`);
}
}
}
}, 50);
/*
Makes HNES more compact, like the original hacker news layout.
To be used with the Stylus extension.
*/
/* Restore Original HN Style */
form textarea {
height: 40px;
}
body > center > table {
width: 85% !important;
}
#hnes-comments {
font-family: Verdana, Geneva, sans-serif !important;
font-size: 9pt !important;
line-height: normal !important;
}
body .hnes-comment {
background-color: #F6F6EF !important;
padding: 4px 4px 4px 4px;
margin: 0 0 6px 0;
}
.hnes-comment.hnes-new-parent {
border-left: none;
}
p {
margin-block: 6px;
}
#hnes-comments .replies {
margin: 6px 0 0 30px !important;
}
.hnes-comment .text {
max-width: 1215px !important;
}
#hnes-comments a {
color: #555 !important;
}
#hnes-comments .body a:link {
text-decoration: underline !important;
}
#hnes-comments a:visited {
color: #888 !important;
}
.hnes-user-score-cont, .hnes-user-score-cont * {
color: #880202 !important;
}
body .hnes-comment .collapser {
display: block;
margin-left: 3px;
margin-right: 7px;
width: 14px;
cursor: pointer;
}
.hnes-tagText:not(:empty) {
border: 1px solid black;
border-radius: 3px;
padding: 1px 4px 1px 4px !important;
background-color: #eee;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment