Last active
August 29, 2015 14:11
-
-
Save uadev/4e37fdfd521524bcc740 to your computer and use it in GitHub Desktop.
Complete Bookmarklet for GitHub release notes
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
/** @global ZeroClipboard **/ | |
function addTab(text) { | |
var li = document.createElement('li'); | |
var c = new ZeroClipboard(li); | |
c.on('copy', function(e) { | |
e.clipboardData.setData('text/plain', text); | |
li.innerHTML = 'Notes <small><b>(copied)<b></small>'; | |
}); | |
li.classList.add('tabnav-tab'); | |
li.innerText = 'Copy Notes'; | |
li.style.cursor = 'pointer'; | |
document.querySelector('.tabnav-tabs').appendChild(li); | |
}; | |
function getNotes() { | |
return Array.prototype.map.call( | |
document.querySelectorAll('.comment-body > p'), | |
function(c) { return '\\' + c.innerHTML;} | |
).join("\n") | |
}; | |
addTab(getNotes()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment