Skip to content

Instantly share code, notes, and snippets.

@wenqingyu
Created July 18, 2017 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wenqingyu/37e96c48774b9c397aa5acb4af4bccc5 to your computer and use it in GitHub Desktop.
Save wenqingyu/37e96c48774b9c397aa5acb4af4bccc5 to your computer and use it in GitHub Desktop.
juejin-translate-labels.js
[
{
"name": "AI",
"color": "5319e7"
},
{
"name": "Android",
"color": "1d76db"
},
{
"name": "closing-soon-if-no-response",
"color": "d93f0b"
},
{
"name": "enhancement",
"color": "1d76db"
},
{
"name": "iOS",
"color": "1d76db"
},
{
"name": "merging-soon-if-no-other-reviewer",
"color": "d93f0b"
},
{
"name": "needs-review",
"color": "5319e7"
},
{
"name": "请到对应的 PR 下认领校对",
"color": "fbca04"
},
{
"name": "前端",
"color": "1d76db"
},
{
"name": "后端",
"color": "1d76db"
},
{
"name": "好评如潮",
"color": "5319e7"
},
{
"name": "延期啦,大大们赶紧哒",
"color": "b60205"
},
{
"name": "校对认领",
"color": "ff5722"
},
{
"name": "正在校对",
"color": "c2e0c6"
},
{
"name": "正在翻译",
"color": "c5def5"
},
{
"name": "申请译者",
"color": "d4c5f9"
},
{
"name": "系列任务",
"color": "0e8a16"
},
{
"name": "翻译完成",
"color": "c5def5"
},
{
"name": "翻译认领",
"color": "d93f0b"
},
{
"name": "设计&产品",
"color": "1d76db"
},
{
"name": "质量较差",
"color": "563d7c"
},
{
"name": "重复翻译",
"color": "cccccc"
},
{
"name": "问题标注",
"color": "b60205"
}
].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('.label-edit-name').value = label.name
element.querySelector('.color-editor-input').value = '#' + label.color
element.querySelector('.new-label-actions .btn-primary').click()
}
})
return flag
}
function addNewLabel (label) {
document.querySelector('.new-label input#label-').value = label.name
document.querySelector('.new-label input#edit-label-color-new').value = '#' + label.color
document.querySelector('.new-label-actions .btn-primary').click()
}
function addLabel (label) {
if (!updateLabel(label)) addNewLabel(label)
}
undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment