Skip to content

Instantly share code, notes, and snippets.

@Aleksandr-ru
Last active February 3, 2022 10:23
Show Gist options
  • Save Aleksandr-ru/6d6869c67a9d8f22259b6bd0cbf6e3f8 to your computer and use it in GitHub Desktop.
Save Aleksandr-ru/6d6869c67a9d8f22259b6bd0cbf6e3f8 to your computer and use it in GitHub Desktop.
Просмотр истории и diff карточки в Trello
// в открытой карточке выполнить в консоли
(function () {
const id = window.location.pathname.match(/\/c\/([^/]+)/)?.pop();
const script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jsdiff/4.0.1/diff.js';
document.head.appendChild(script);
script.onload = function () {
fetch(`https://trello.com/1/cards/${id}/actions?filter=updateCard:desc`).then(response => response.json()).then(_history => {
console.clear();
const added = 'color:green';
const removed = 'color:red';
const noChange = '';
_history.filter(el=>el.data.card.hasOwnProperty('desc')).map(el => {
let resultString = '';
const dt = new Date(el.date);
const group = el.memberCreator.fullName + ', ' + dt.toLocaleString('ru');
const resultColors = [];
const diff = Diff.diffWords(el.data.old.desc, el.data.card.desc);
diff.forEach(function (part) {
if (part.added) {
resultColors.push(added);
} else if (part.removed) {
resultColors.push(removed);
} else {
resultColors.push(noChange);
}
resultString += '%c' + part.value;
});
console.group(group);
console.log(resultString, ...resultColors);
console.groupEnd(group);
});
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment