-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
25 lines (20 loc) · 895 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const createCategory = (categoryName) => {
// Open the add category form
document.querySelector(".category-tree-view span[data-ember-action]").click()
// Fill in the name of the category
const inputEl = document.querySelector(".category-form .ember-text-field")
inputEl.value = categoryName
inputEl.dispatchEvent(new Event("input", { bubbles: true }))
// Submit the form
document.querySelector(".category-form button[type='submit']").click()
}
const categoryNames = prompt("Enter category names separated by commas")
const categoryNamesArray = categoryNames.split(",")
// Trim whitespaces from category names
categoryNamesArray.map((categoryName) => categoryName.trim())
// Loop over the category names and create them, wait a sec between each
categoryNamesArray.forEach((categoryName, index) => {
setTimeout(() => {
createCategory(categoryName)
}, index * 1000)
})