From f99af36f48e10856523ba2810ee35c9ed14460be Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 4 Aug 2021 16:02:23 +0300 Subject: [PATCH] [BZ Fresh UI] Added formatting for ticket changes --- bz_fresh_ui.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/bz_fresh_ui.js b/bz_fresh_ui.js index 3acef40..93d3686 100644 --- a/bz_fresh_ui.js +++ b/bz_fresh_ui.js @@ -84,7 +84,7 @@ async function formatComments() { log('Started'); const headers = [...document.getElementsByClassName('bz_comment_head'), - ...document.getElementsByClassName('bz_first_comment_head')]; + ...document.getElementsByClassName('bz_first_comment_head')]; log(`Found ${headers.length} headers to add avatars to`); headers.forEach(async header => { if ([...header.getElementsByClassName('sd_bz_user_avatar')].length) return; @@ -103,7 +103,26 @@ img.src = userAvatar; wrapper.appendChild(img); header.insertBefore(wrapper, header.firstChild); - }) + }); + const historyChanges = [...document.getElementsByClassName('ih_history_change')]; + log(`Found ${historyChanges.length} changes sections to format.`); + historyChanges.forEach(h => { + const lines = h.innerText.split('\n'); + const newLines = []; + lines.forEach(l => { + const tab = newLines.length ? '               ' : ''; + if (l.indexOf('→') != -1) { + newLines.push(`${tab}🔀 ${l.replace('→', '🢧')}`); + } + else if (l.indexOf('CC') != -1) { + newLines.push(`${tab}🙋 ${l}`); + } + else { + newLines.push(`${tab}🔼 ${l}`); + } + }); + h.innerHTML = newLines.join('
') + }); }