-
-
Save bakkot/3d8c5000cea9c41e6923453d30fd6550 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name SSC: More Up | |
// @namespace https://github.com/bakkot/SlateStarComments/ | |
// @description Add links to OPs of threads on SSC and Unsong | |
// @match http://slatestarcodex.com/20* | |
// @match http://unsongbook.com/* | |
// @version 1.0.0 | |
// ==/UserScript== | |
var comments = document.querySelectorAll('li.comment'); | |
for (var i=0; i<comments.length; ++i) { | |
if (comments[i].parentElement.tagName === 'UL') { | |
var commentHolder = comments[i].querySelector('div.commentholder'); | |
var parent = comments[i]; | |
do { | |
parent = parent.parentElement.parentElement; | |
} while (parent.parentElement.tagName === 'UL'); | |
var parentID = parent.firstElementChild.id; | |
var parentLink = document.createElement('a'); | |
parentLink.href = '#' + parentID; | |
parentLink.className = 'comment-reply-link'; | |
parentLink.style.textDecoration = 'underline'; | |
parentLink.title = 'OP comment'; | |
parentLink.textContent = '⇑'; | |
var replyEle = commentHolder.querySelector('div.reply'); | |
replyEle.appendChild(document.createTextNode(' ')); | |
replyEle.appendChild(parentLink); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment