Created
February 18, 2017 17:56
-
-
Save XtinaSchelin/8b1dc7ca3da56fa2b5ee9e1abce4259e to your computer and use it in GitHub Desktop.
Add comment links to Captain Awkward comments.
This file contains hidden or 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 Captain Awkward Comments Link | |
| // @namespace https://twitter.com/XtinaSchelin | |
| // @version 0.1 | |
| // @description Add comment links to Captain Awkward comments. | |
| // @author XtinaS | |
| // @match https://captainawkward.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| // Get the current URL. Split out the comment #s, if there are any. | |
| var loke = window.location.href; | |
| loke = loke.split("#")[0]; | |
| // Get all <article> tags in the doc. | |
| var all_articles = document.getElementsByTagName("article"); | |
| for (var x = 0; x < all_articles.length; x++) { | |
| var this_article = all_articles[x]; | |
| if (this_article.getAttribute("class") == "comment") { | |
| // Get the ID and time. | |
| var art_id = this_article.getAttribute("id"); | |
| var this_time = this_article.getElementsByTagName("time")[0]; | |
| // Make the link. | |
| this_time.innerHTML = '<a href="' + loke + '#' + art_id + '">' + this_time.innerHTML + '</a>'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment