Skip to content

Instantly share code, notes, and snippets.

@westonwatson
Created October 1, 2019 13:11
Show Gist options
  • Save westonwatson/d47893c5f1b05ba13954520c80fd3dca to your computer and use it in GitHub Desktop.
Save westonwatson/d47893c5f1b05ba13954520c80fd3dca to your computer and use it in GitHub Desktop.
Hacker News OUTLINE.COM links
//Run this code after page load
window.onload = function() {
//target story link container(s)
document.querySelectorAll('.storyLink').forEach(
function(nodeObj, objIndex) {
var parentNode = nodeObj.parentNode;
//make a copy of the story link
var cloneNode = nodeObj.cloneNode(true);
var hrefString = nodeObj.href;
//create the outline.com link
hrefString = 'https://outline.com/' + hrefString;
//set href and open in new tab
cloneNode.href = hrefString;
cloneNode.target = '_blank';
//leave a copy of the original link
nodeObj.innerHTML = ' [DIRECT LINK]';
//append the outline link/copy
parentNode.prepend(cloneNode);
}
);
}