Last active
January 3, 2018 19:00
-
-
Save devNoiseConsulting/a33f53423011e296ab804303682b6677 to your computer and use it in GitHub Desktop.
A javascript snippet to extract the description and link of each gist on the page.
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
| // Starting point was based off of an answer on StackOverflow | |
| // https://stackoverflow.com/a/3824292/187675 | |
| let grabMyGists = function(userName, linkMatch, descMatch) { | |
| let links = [...document.links].filter( | |
| link => | |
| link.hostname === location.hostname && | |
| link.href.includes(userName) && | |
| link.text.match(linkMatch) | |
| ); | |
| let descriptions = [...document.getElementsByClassName('description')].filter( | |
| description => description.innerText.match(descMatch) | |
| ); | |
| links.forEach((link, i) => { | |
| let description = descriptions[i]; | |
| console.log(description.innerText, link.href, link.text); | |
| }); | |
| }; | |
| grabMyGists('/devNoiseConsulting/', /^ac/, /- Advent of Code -/); | |
| /* | |
| In Atom editor: | |
| find: ^(.*) - .* - (2017[0-9]+).*(https.*) dp.*$ | |
| replace: - [$1 Gist - $2]($3) | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment