Skip to content

Instantly share code, notes, and snippets.

@alexgb
Last active August 29, 2015 14:11
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 alexgb/d9139855733c5b79e55f to your computer and use it in GitHub Desktop.
Save alexgb/d9139855733c5b79e55f to your computer and use it in GitHub Desktop.
var match = location.href.match(/trello\.com\/([[cb])\/(.*)\//),
cookies, token, boardId, data;
if (match[1] === 'c') {
boardId = window.IdCache.getBoardIdForCard(match[2]);
} else {
boardId = window.IdCache.getBoardId(match[2]);
}
cookies = document.cookie.split('; ').reduce(function(memo, i) {
var parts = i.split('=');
memo[parts[0]] = parts[1];
return memo;
}, {});
token = decodeURIComponent(cookies.token);
$.ajax({
type: 'get',
url: '/1/boards/' + boardId,
data: { labels: 'all' }
}).then(function(board) {
board.labels.forEach(function(label) {
if (!label.name) {
$.ajax({
type: 'delete',
url: '/1/labels/' + label.id,
data: { token: token }
}).then(function() {
console.log('deleted', label.color, label.id);
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment