Skip to content

Instantly share code, notes, and snippets.

@alexgb
Last active August 29, 2015 14:09
Show Gist options
  • Save alexgb/e45243ba4ce17eaf1726 to your computer and use it in GitHub Desktop.
Save alexgb/e45243ba4ce17eaf1726 to your computer and use it in GitHub Desktop.
var match = location.href.match(/trello\.com\/([[cb])\/(.*)\//),
copiedLabels = JSON.parse(localStorage.getItem('copiedLabels')),
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);
data = {}
for (var attr in window.copiedLabels) {
data['labelNames/' + attr] = window.copiedLabels[attr];
}
data.token = token;
$.ajax({
type: 'put',
url: '/1/boards/' + boardId,
data: data
}).then(function() {
console.log('Pasted labels');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment