Skip to content

Instantly share code, notes, and snippets.

@contactjavas
Created August 28, 2020 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save contactjavas/8ab3a5f66d2432f62385bd90db7ed11c to your computer and use it in GitHub Desktop.
Save contactjavas/8ab3a5f66d2432f62385bd90db7ed11c to your computer and use it in GitHub Desktop.
Get Font Awesome 5 Unicodes
/**
* Font Awesome Free
*
* https://fontawesome.com/cheatsheet/free/solid
* https://fontawesome.com/cheatsheet/free/regular
* https://fontawesome.com/cheatsheet/free/brands
*
* Visit pages above, paste this code to the console and enter.
* Copy the result and beautify it in https://codebeautify.org/jsonviewer
*/
(function () {
var icons = {};
const sets = document.querySelectorAll("section.cheatsheet-set");
sets.forEach((set) => {
let prefix = "";
switch (set.id) {
case "regular":
prefix = "far";
break;
case "solid":
prefix = "fas";
break;
case "light":
prefix = "fal";
break;
case "brands":
prefix = "fab";
break;
}
const articles = set.querySelectorAll("article.icon");
articles.forEach((article) => {
const iconClass = prefix + " fa-" + article.id;
let unicode = article.querySelector("dd.icon-unicode").innerHTML;
unicode = "\\" + unicode;
icons[iconClass] = unicode;
});
});
return JSON.stringify(icons);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment