Created
March 11, 2015 11:06
-
-
Save evenfrost/2fa133a462cb4079ffa1 to your computer and use it in GitHub Desktop.
Sets emoji icons for tasks in Trello.
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
/** | |
* Sets emoji icons for tasks. | |
*/ | |
var emojize = function () { | |
var tasks = Array.prototype.slice.call(document.querySelectorAll('.checklist-item:not(.checklist-item-state-complete)')), | |
i = 0, | |
len = tasks.length, | |
replacers = [ | |
{ | |
from: '/^low:\s/', | |
to: 'low: ' | |
}, | |
{ | |
from: /^norm:\s/, | |
to: ':exclamation: norm: ' | |
}, | |
{ | |
from: /^high:\s/, | |
to: ':bangbang: high: ' | |
}, | |
{ | |
from: /^extra high:\s/, | |
to: ':bangbang: extra high:' | |
} | |
]; | |
function processTask() { | |
var task = tasks[i], | |
desc = task.querySelector('.checklist-item-details-text'), | |
area; | |
area = task.querySelector('textarea.field'), | |
desc.click(); | |
replacers.forEach(function (replacer) { | |
area.value = area.value.replace(replacer.from, replacer.to); | |
}) | |
setTimeout(function() { | |
task.querySelector('input[type="submit"]').click(); | |
}, 50); | |
if (i + 1 !== len) { | |
i++; | |
setTimeout(processTask, 100) | |
} | |
} | |
processTask(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment