Skip to content

Instantly share code, notes, and snippets.

@devNoiseConsulting
Last active January 3, 2018 19:00
Show Gist options
  • Select an option

  • Save devNoiseConsulting/a33f53423011e296ab804303682b6677 to your computer and use it in GitHub Desktop.

Select an option

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.
// 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