Created
August 4, 2017 22:46
-
-
Save Dbof/b71e50a67c743a930385f0237bf50856 to your computer and use it in GitHub Desktop.
Properly copy names on click without spaces issue
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 BugMeNot ProperCopy | |
// @namespace com.davidebove.blog | |
// @description Properly copy names on click without spaces issue. See https://bugzilla.mozilla.org/show_bug.cgi?id=1298706 | |
// @match http://bugmenot.com/view/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
function copyToClipboard(element) { | |
var target = $(element.target); | |
var $temp = $('<input>'); | |
$('body').append($temp); | |
$temp.val(target.text()).select(); | |
document.execCommand('copy'); | |
$temp.remove(); | |
var oldtext = target.text(); | |
target.text('Copied to clipboard!'); | |
setTimeout(function() { | |
target.text(oldtext); | |
}, 1000) | |
} | |
$('kbd').each(function (i, obj) { | |
$(obj).click(copyToClipboard); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment