Created
March 13, 2020 11:54
-
-
Save sasha240100/dafdad417eb0d1223b9f7d6413004826 to your computer and use it in GitHub Desktop.
This file contains 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 characters
function traverse(data) { | |
return Array.from(data).map(item => { | |
const name = item.innerText.split('\n')[0].trim(); | |
const skill = { | |
value: name.toLowerCase(), | |
label: name | |
}; | |
if (item.children.length !== 0) { | |
skill.children = traverse(item.children[0].children); | |
} | |
return skill; | |
}) | |
} | |
function copyToClipboard(text) { | |
window.prompt("Copy to clipboard: Ctrl+C, Enter", text); | |
} | |
function generateJsonFromSkillsList() { | |
const data = document.querySelector('#Placeholderdatamockups-skills').parentNode.parentElement.querySelector('ul'); | |
const result = JSON.stringify(traverse(data.children)); | |
copyToClipboard(result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment