Browser Devtool console is Figma's best scripting tool, FigmaConsoleKit can make it better, add a debugging-friendly API, most commonly used libraries(axios
,lodash
,mathjs
,Color
,font-color-contrast
).
- paste code into figma console
fetch(
"https://raw.githubusercontent.com/Moonvy/FigmaConsoleKit/master/dist/FigmaConsoleKit.js?v1.5.0"
).then((r) => r.text().then((c) => eval(c)));
or
- create a browser bookmark and add the code as address
javascript:(function()%7Bfetch(%22https%3A%2F%2Fraw.githubusercontent.com%2FMoonvy%2FFigmaConsoleKit%2Fmaster%2Fdist%2FFigmaConsoleKit.js%3Fv1.5.0%22).then((r)%20%3D%3E%20r.text().then((c)%20%3D%3E%20eval(c)))%7D)()
or
- paste the code into console
- π₯
activeNodes
currently selected layers (multiple) - π₯
activeNode
currently selected layer (only one is fetched) getChildrenByName(node)
get multiple sublayers by layer namegetClidByName(node)
get a sublayer by layer namegetNodes(node, eachFunc)
get nodes from all children by eachFunc.getNodesByName(node, name)
get nodes with the specified name from all childrengetNodesByType(node, type)
get nodes with the specified type from all childrengetNodesByTypeName(node, type, name)
get nodes with the specified type and name from all children
show(node)
Show layer informationjson(node)
converts the layer information into a JSON string
toFloatColor(intColor)
[255,255,255] => {r:1.0, g:1.0, b:1.0}toIntColor(floatColor)
{r:1.0, g:1.0, b:1.0} => [255,255,255]
loadNodeFonts(node)
prepare the font used for a layersetNodeText(node, text)
set the text content of the text layer
tidyX(nodes, cols, gap)
rearrange layers by number of columns
download([{name, input}])
download multiple Unit8Array as zip file (client-zip).downloadZip()
(client-zip).
axios
best JavaScript HTTP client.font-color-contrast
use black or white font according to the given background color.lodash
a modern JavaScript utility library delivering modularity, performance & extras.mathjs
an extensive math library.client-zip
download all the files in one click.Color
immutable color conversion and manipulation with support for CSS color strings.