Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bitzip/1173743d2884dce0b8b1dd4b60125f23 to your computer and use it in GitHub Desktop.
Save bitzip/1173743d2884dce0b8b1dd4b60125f23 to your computer and use it in GitHub Desktop.
Fontawesome click icon to copy icon name to clipboard
// ==UserScript==
// @name fontawesome copy icon name
// @namespace https://gist.github.com/kelly-apollo/1173743d2884dce0b8b1dd4b60125f23
// @version 0.2
// @description try to take over the world!
// @author Kelly Apollo
// @match http://fontawesome.io/icons/
// @grant GM_setClipboard
// ==/UserScript==
(function() {
'use strict';
document.querySelector('#icons').addEventListener('click', e => {
var target = e.target;
var match = target.href && target.href.match(/icon\/(.*)/);
if (match) {
target.style.color = '#000';
setTimeout(()=>target.style.color = '', 200);
GM_setClipboard(match[1]);
e.stopPropagation();
e.preventDefault();
}
}, true);
})();
@davehamer
Copy link

Does this still work for you? The page seems to 'reload' which seems to cause Greasemonkey scripts to not work correctly.

I'm trying to write a similar script to change the quotation marks on the 'embed code' to single quotes instead of double.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment