Last active
September 15, 2017 06:59
-
-
Save voltrevo/71188b20256616e9c1911911f83717a1 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
'use strict'; | |
const rows = Array.prototype.slice.apply( | |
document.querySelectorAll('.js-file-line') | |
); | |
const code = rows | |
.map(el => | |
el.innerHTML | |
.replace(/<[^>]*>/g, '') | |
.replace(/</g, '<') | |
.replace(/>/g, '>') | |
.replace(/&/g, '&') | |
.replace(/%0A/g, escape('%0A')) | |
) | |
.join('%0A') | |
; | |
const lnk = document.createElement('a'); | |
lnk.href = `javascript:(()=>{${code}})()`; | |
lnk.textContent = document.title; | |
lnk.setAttribute('class', 'btn btn-sm'); | |
document.querySelector('.file-actions').appendChild(lnk); |
Actually, on second thought, I dislike hyphens
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like this lots ;-)