Last active
August 15, 2025 08:27
-
-
Save vdawg-git/e37112eb7caa9990ef32fd3610d59b54 to your computer and use it in GitHub Desktop.
Revisions
-
vdawg-git revised this gist
Aug 15, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -68,7 +68,7 @@ function getColumnNames() { */ function getRowPathFromRow(row) { if (isPathRow(row)) { return row.innerText.split("\n") } return getRowPathFromRow(row.previousSibling) -
vdawg-git revised this gist
Aug 15, 2025 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,6 @@ function getRows() { */ function getDataFromRow(row, columns) { const path = getRowPathFromRow(row) const [name, ...items] = [...row.querySelectorAll("td")].map( (element) => element.innerText ) -
vdawg-git revised this gist
Aug 14, 2025 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,9 @@ /* Just paste and run it in the devtools. Then you can copy the resulting array. This gets the variables from the current table in the Figma Variables overview. Last update: 14.08.2025 */ console.log(getVars()) -
vdawg-git revised this gist
Aug 14, 2025 . 1 changed file with 65 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,32 +1,87 @@ /* Just copy paste all this into the console. This gets the variables from the current table in the Figma Variables overview. Just paste and run it in the devtools. Then you can copy the resulting array. Last update: 12.08.2025 */ console.log(getVars()) /** * The element of the returned array * @typedef {Object} VariableItem * @property {string[]} path Something like [ "grey" ] or [ "button", "primary" ] * @property {string} name * @property {Record<string, string>} values */ function getVars() { const columnNames = getColumnNames() const data = getRows().map((row) => getDataFromRow(row, columnNames)) if (!data) { throw new Error("No table with variables found. R u on the right page?") } return data } /** @returns {HTMLTableRowElement[]} */ function getRows() { return $$("table tr:has(td button[data-fpl-component])") } /** * @param {HTMLTableRowElement} row * @param {readonly string[]} columns Excluding `name` * @returns {VariableItem} */ function getDataFromRow(row, columns) { const path = getRowPathFromRow(row) console.log({ path }) const [name, ...items] = [...row.querySelectorAll("td")].map( (element) => element.innerText ) if (!items) { console.log(row) } const values = Object.fromEntries( items.map((text, index) => [columns[index], text]) ) return { name, path, values } } /** * @returns {readonly string[]} The names of the columns, excluding `name` as its always there */ function getColumnNames() { return $$("table tbody>tr:first-child td") .map((item) => item.innerText) .filter((_, index) => index !== 0) .filter(Boolean) } /** * @param {HTMLTableRowElement} row * @returns {readonly string[]} */ function getRowPathFromRow(row) { if (isPathRow(row)) { return row.innerText.split("/") } return getRowPathFromRow(row.previousSibling) } /** * @param {HTMLTableRowElement} row * @returns {boolean} */ function isPathRow(row) { return row.querySelectorAll("td").length === 1 } -
vdawg-git created this gist
Aug 12, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ /* This gets the variables from the current table in the Figma Variables overview. Just paste and run it in the devtools. Then you can copy the resulting array. Last update: 12.08.2025 */ function getVars() { const data = getRows().map(getDataFromRow); if (!data) { throw new Error('No table with variables found. R u on the right page?'); } console.log(data); } /** @returns {HTMLTableRowElement[]} */ function getRows() { return $$('table tr:has(td button[data-fpl-component])'); } /** * @param {HTMLTableRowElement} row * @returns { string[] } */ function getDataFromRow(row) { return [...row.querySelectorAll('td')].map((element) => element.innerText); } getVars();