Created
October 1, 2019 13:11
-
-
Save westonwatson/d47893c5f1b05ba13954520c80fd3dca to your computer and use it in GitHub Desktop.
Hacker News OUTLINE.COM links
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
//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); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a list of Chrome/Chromium Extensions you can use to inject Javascript (and CSS) into pages...