Last active
December 17, 2020 16:24
-
-
Save pastukh-dm/bb4cb5e5c44edd2e71288c3cb6c2e2c4 to your computer and use it in GitHub Desktop.
Import GitHub labels
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
// Import GitHub labels | |
.forEach(function(label) { | |
addLabel(label) | |
}) | |
function updateLabel (label) { | |
var flag = false; | |
[].slice.call(document.querySelectorAll(".labels-list-item")) | |
.forEach(function(element) { | |
if (element.querySelector('.label-link').textContent.trim() === label.name) { | |
flag = true | |
element.querySelector('.js-edit-label').click() | |
element.querySelector('.js-new-label-name-input').value = label.name | |
element.querySelector('.js-new-label-description-input').value = label.description | |
element.querySelector('.js-new-label-color-input').value = '#' + label.color | |
element.querySelector('.js-edit-label-cancel ~ .btn-primary').click() | |
} | |
}) | |
return flag | |
} | |
function addNewLabel (label) { | |
document.querySelector('.js-new-label-name-input').value = label.name | |
document.querySelector('.js-new-label-description-input').value = label.description | |
document.querySelector('.js-new-label-color-input').value = '#' + label.color | |
document.querySelector('.js-details-target ~ .btn-primary').disabled = false | |
document.querySelector('.js-details-target ~ .btn-primary').click() | |
} | |
function addLabel (label) { | |
if (!updateLabel(label)) addNewLabel(label) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment