Last active
October 21, 2015 22:14
-
-
Save himedlooff/3fa7653f2ab9e6921adb to your computer and use it in GitHub Desktop.
Paste this into your console to enable click-to-copy on GitHub.com file paths
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
(function(){ | |
$('.file-info[title], .file-info [title]') | |
.css('cursor', 'pointer') | |
.click(function() { | |
var range = document.createRange(); | |
$(this).html($(this).attr('title')); | |
range.selectNode(this); | |
window.getSelection().addRange(range); | |
try { | |
var successful = document.execCommand('copy'); | |
var msg = successful ? 'successful' : 'unsuccessful'; | |
console.log('Copying', range.toString(), 'was', msg); | |
} catch(err) { | |
console.log('Oops, unable to copy'); | |
} | |
window.getSelection().removeAllRanges(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can sue http://mrcoles.com/bookmarklet/ to generate a bookmarklet as well