Skip to content

Instantly share code, notes, and snippets.

@chapko
Created October 24, 2016 19:32
Show Gist options
  • Save chapko/601a589659533c30c099d65d09d90be2 to your computer and use it in GitHub Desktop.
Save chapko/601a589659533c30c099d65d09d90be2 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://gist.github.com/*
// @grant none
// ==/UserScript==
// jshint esnext: true
(function() {
'use strict';
const fileElements = document.querySelectorAll('.file');
const files = Array.from(fileElements).map((fileElement) => {
const nameElement = fileElement.querySelector('.gist-blob-name');
const actionsElement = fileElement.querySelector('.file-actions');
const name = nameElement.textContent.trim();
const link = nameElement.parentElement.href;
const rawLink = actionsElement.firstElementChild.href;
return { name, link, rawLink };
});
const content = files
.map(({ name, rawLink }) => `- [${name}](${rawLink})`)
.join('\n');
const code = document.createElement('pre');
code.textContent = content;
const meta = document.querySelector('.repository-meta');
meta.classList.add('markdown-body');
meta.appendChild(code);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment