Skip to content

Instantly share code, notes, and snippets.

@knz21
Created March 9, 2018 01:25
Show Gist options
  • Save knz21/2f6e1b42cac767239deb3b90402d6c32 to your computer and use it in GitHub Desktop.
Save knz21/2f6e1b42cac767239deb3b90402d6c32 to your computer and use it in GitHub Desktop.
Copy github commit messages.
var commits = '';
Array.prototype.slice.call(document.getElementsByTagName('code')).filter(function (code) {
return code.children[0].classList.contains("message");
}).forEach(function (code) {
var commit = code.children[0].text;
if (commit.indexOf('Merge') != 0) commits += commit + "\r";
});
var body = document.getElementsByTagName('body')[0];
var span = document.createElement('span');
span.textContent = commits;
body.appendChild(span);
var range = document.createRange();
range.selectNodeContents(span);
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
document.execCommand('copy');
selection.removeAllRanges();
body.removeChild(span);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment