Bookmarklet Enhancement: Effortlessly enhance your browsing experience on the Hacker News page by executing this script directly in the console. This addition seamlessly integrates similarity links into the main site, significantly boosting usability. For even greater convenience, save this script as a bookmarklet in your browser, enabling you to activate these links with a single click. Experience streamlined navigation and functionality at your fingertips!
You can find the bookmarklet code:
javascript: (function () {
var item_tags = document.getElementsByClassName("athing");
for (let index = 0; index < item_tags.length; index++) {
var item_tag = item_tags[index];
var item_id = item_tag.id;
var item = item_tag.getElementsByClassName("titleline");
if (item.length > 0) {
story_tag = item[0];
var wrapperSpan = document.createElement('span');
wrapperSpan.className = 'sitebit comhead';
var innerSpan = document.createElement('span');
innerSpan.className = "sitestr";
innerSpan.textContent = 'similar stories';
var anchorElement = document.createElement('a');
anchorElement.textContent = " ";
anchorElement.target = "_blank";
anchorElement.href = 'https://hn.garglet.com/similar/stories/' + item_id;
anchorElement.appendChild(innerSpan);
wrapperSpan.appendChild(anchorElement);
story_tag.appendChild(wrapperSpan);
}
else {
var nav_tags = item_tag.getElementsByClassName("navs")[0];
var anchorElement = document.createElement('a');
anchorElement.textContent = " similar comment";
anchorElement.target = "_blank";
anchorElement.href = 'https://hn.garglet.com/similar/comment/' + item_id;
nav_tags.appendChild(anchorElement);
}
}
})();