Skip to content

Instantly share code, notes, and snippets.

@evenfrost
Created March 11, 2015 11:06
Show Gist options
  • Save evenfrost/2fa133a462cb4079ffa1 to your computer and use it in GitHub Desktop.
Save evenfrost/2fa133a462cb4079ffa1 to your computer and use it in GitHub Desktop.
Sets emoji icons for tasks in Trello.
/**
* 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