aboutsummaryrefslogtreecommitdiff
path: root/scripts/fontawesome-menu/populate-fontsheet.js
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-12-24 00:06:27 +0530
committerAkshay Nair <phenax5@gmail.com>2020-12-24 00:06:27 +0530
commit865728068c965e066d0f8971c5b5ba26e12e7dce (patch)
treec16195f0a04cf7d004fe5b396255734f4d60bb00 /scripts/fontawesome-menu/populate-fontsheet.js
parent649ef5f225039e498358c3d056dfd7fcbc56f014 (diff)
downloadnixos-config-865728068c965e066d0f8971c5b5ba26e12e7dce.tar.gz
nixos-config-865728068c965e066d0f8971c5b5ba26e12e7dce.zip
Adds scripts and links scripts and wallpapers
Diffstat (limited to '')
-rw-r--r--scripts/fontawesome-menu/populate-fontsheet.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/fontawesome-menu/populate-fontsheet.js b/scripts/fontawesome-menu/populate-fontsheet.js
new file mode 100644
index 0000000..c41f7ad
--- /dev/null
+++ b/scripts/fontawesome-menu/populate-fontsheet.js
@@ -0,0 +1,54 @@
+const puppeteer = require('puppeteer');
+const fs = require('fs');
+const path = require('path');
+
+const getTabBtnSelector = type => `[href="/cheatsheet/free/${type}"]`;
+
+
+const types = ['solid', 'regular', 'brands'];
+
+async function start() {
+ const b = await puppeteer.launch({ headless: true });
+
+ const p = await b.newPage();
+
+ console.log('Downloading...');
+ await p.goto('https://fontawesome.com/cheatsheet/free/solid');
+
+ const icons = {};
+
+ for (const type of types) {
+ await p.click(getTabBtnSelector(type));
+
+ const data = await p.evaluate((type) => {
+ const getClass = type => ({
+ solid: '.fas',
+ regular: '.far',
+ brands: '.fab',
+ })[type];
+
+ return [...document.querySelectorAll(`section article`)]
+ .map($el => ({
+ label: $el.id,
+ icon: $el.querySelector(getClass(type)).textContent,
+ // group: type,
+ }));
+ }, type);
+
+ icons[type] = data;
+ }
+
+ b.close();
+
+ console.log('Saving to icons...');
+ Object.entries(icons).forEach(([type, icons]) => {
+ const iconsContent = icons
+ .map(({ label, icon, group }) => `${icon}|${label}`)
+ .join('\n');
+
+ fs.writeFileSync(path.resolve(__dirname, `icons/${type}`), iconsContent);
+ });
+}
+
+start();
+