Created
October 24, 2016 19:32
-
-
Save chapko/601a589659533c30c099d65d09d90be2 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 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