Last active
May 3, 2022 08:41
-
-
Save dalepgrant/df2e88583f49f16fc7abd7696203228b to your computer and use it in GitHub Desktop.
Update standard Github labels with emoji and add Code& defaults
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 characters
[ | |
{ | |
"name": "automerge", | |
"oldName": "automerge", | |
"description": "Automatically merge PRs with this label", | |
"color": "2db767" | |
}, | |
{ | |
"name": "documentation π", | |
"oldName": "documentation", | |
"description": null, | |
"color": "0075ca" | |
}, | |
{ | |
"name": "seo π±", | |
"oldName": "seo", | |
"description": "Specifically relates to SEO improvements", | |
"color": "f9e795" | |
}, | |
{ | |
"name": "blocker π ββοΈ", | |
"oldName": "blocker", | |
"description": "This blocks another issue from being actioned", | |
"color": "b60205" | |
}, | |
{ | |
"name": "trivial π€·ββοΈ", | |
"oldName": "trivial", | |
"description": null, | |
"color": "bfdadc" | |
}, | |
{ | |
"name": "quick win π", | |
"oldName": "quick win", | |
"description": null, | |
"color": "a4ace8" | |
}, | |
{ | |
"name": "discuss β", | |
"oldName": "discuss", | |
"description": null, | |
"color": "c5def5" | |
}, | |
{ | |
"name": "bug π", | |
"oldName": "bug", | |
"description": "Something isn't working", | |
"color": "d73a4a" | |
}, | |
{ | |
"name": "dependencies π€", | |
"oldName": "dependencies", | |
"description": "Pull requests that update a dependency file", | |
"color": "0366d6" | |
}, | |
{ | |
"name": "duplicate π«", | |
"oldName": "duplicate", | |
"description": "This issue or pull request already exists", | |
"color": "cfd3d7" | |
}, | |
{ | |
"name": "enhancement π", | |
"oldName": "enhancement", | |
"description": "New feature or request", | |
"color": "a2eeef" | |
}, | |
{ | |
"name": "help wanted πββοΈ", | |
"oldName": "help wanted", | |
"description": "Extra attention is needed", | |
"color": "008672" | |
}, | |
{ | |
"name": "P1 β‘", | |
"oldName": "P1", | |
"description": "High priority", | |
"color": "e11d21" | |
}, | |
{ | |
"name": "P2 πββοΈ", | |
"oldName": "P2", | |
"description": "Standard priority", | |
"color": "eb6420" | |
}, | |
{ | |
"name": "P3 ποΈ", | |
"oldName": "P3", | |
"description": "Low Priority", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "question π€", | |
"oldName": "question", | |
"description": "Further information is requested", | |
"color": "d876e3" | |
}, | |
{ | |
"name": "wontfix β°οΈ", | |
"oldName": "wontfix", | |
"description": "This will not be worked on", | |
"color": "ffffff" | |
}, | |
{ | |
"name": "code standards π ", | |
"oldName": "code standards", | |
"description": "This could probably be cleaner", | |
"color": "D9C483" | |
} | |
].forEach(function(label) { | |
addLabel(label) | |
}) | |
function updateLabel (label) { | |
var flag = false; | |
[].slice.call(document.querySelectorAll(".js-labels-list-item")) | |
.forEach(function(element) { | |
// Remove emoji | |
let currentName = element.querySelector('.js-new-label-name-input').value | |
.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, '') | |
.replace(/:.*:/, '') | |
.trim(); | |
if (currentName === label.oldName) { | |
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('.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
Copy/paste this into browser console when viewing a repo's label page