From 6932a72b12cfc6aca7e7825e8ba73f432cadbcb3 Mon Sep 17 00:00:00 2001 From: Shrey Gupta Date: Mon, 30 Sep 2024 14:24:34 +0530 Subject: [PATCH] fix(hubspot): Add toggl button to list view (#2341) --- src/content/hubspot.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/content/hubspot.js b/src/content/hubspot.js index 114bdaaf5..15c5cf5ee 100644 --- a/src/content/hubspot.js +++ b/src/content/hubspot.js @@ -30,3 +30,28 @@ togglbutton.render( } } ); + +// This generic implementation works for most objects details page +togglbutton.render( + 'td[data-table-external-id*="name-"]:not(.toggl)', + { observe: true }, + $container => { + try { + function descriptionSelector() { + return $('[data-test-id="truncated-object-label"]', $container).textContent.trim(); + } + + const link = togglbutton.createTimerLink({ + className: 'hubspot-list-item', + description: descriptionSelector, + buttonType: 'minimal' + }); + const rowContainer = document.createElement('div'); + rowContainer.setAttribute('class', 'flex-row align-center'); + rowContainer.appendChild(link); + $('.media', $container).prepend(rowContainer); + } catch (e) { + console.error(e) + } + } +);