From d9a1fb988875968106b6cc28237e52674ae88f60 Mon Sep 17 00:00:00 2001 From: reignmaker Date: Sat, 14 Oct 2023 15:57:43 +0300 Subject: [PATCH] Update zendesk.js return the code introduced in Apr 2023 as it still works for other users --- src/content/zendesk.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/content/zendesk.js b/src/content/zendesk.js index f17f394e4..25f91171e 100644 --- a/src/content/zendesk.js +++ b/src/content/zendesk.js @@ -39,6 +39,48 @@ setTimeout(() => { }, 1000); +// Zendesk new UI Apr 2023 +setTimeout(() => { + togglbutton.render( + '[data-garden-id="pane"]:not(.toggl)', + { observe: true }, + function (elem) { + if (elem.id === ':r1:--primary-pane') return + let description; + const projectName = $('title').textContent; + + const titleFunc = function () { + const titleElem = $('[data-test-id="omni-header-subject"]', elem); + const ticketNum = location.href.match(/tickets\/(\d+)/); + + if (titleElem !== null) { + description = titleElem.value.trim(); + } + + if (ticketNum) { + description = '#' + ticketNum[1].trim() + ' ' + description; + } + return description; + }; + + const link = togglbutton.createTimerLink({ + className: 'zendesk', + description: titleFunc, + projectName: projectName && projectName.split(' - ').shift() + }); + + // Check for strange duplicate buttons. Don't know why this happens in Zendesk. + if (document.querySelector('.toggl-button')) { + document.removeChild(elem.querySelector('.toggl-button')); + } + elem.querySelector('[data-side-conversations-anchor-id="1"]').firstChild + .firstChild + .firstChild + .appendChild(link); + } + ); +}, 1000); + // Zendesk new UI Sept 2023 setTimeout(() => { togglbutton.render(