From 80798086a95d0e5268e73a343e21137597d7b34a Mon Sep 17 00:00:00 2001 From: Pascal Martineau Date: Wed, 16 Oct 2019 16:41:27 -0400 Subject: [PATCH] feat: Freedcamp integration --- src/content/freedcamp.js | 47 ++++++++++++++++++++++++++++++++++++++++ src/origins.js | 4 ++++ src/styles/style.css | 6 +++++ 3 files changed, 57 insertions(+) create mode 100644 src/content/freedcamp.js diff --git a/src/content/freedcamp.js b/src/content/freedcamp.js new file mode 100644 index 000000000..c2f301960 --- /dev/null +++ b/src/content/freedcamp.js @@ -0,0 +1,47 @@ +/** + * @name SampleScript + * @urlAlias script_a_shortcode + * @urlRegex app.sample.com + */ +'use strict'; + +function tagsSelector() { + const tagsElem = document.querySelectorAll('.AgTagItem--fk-AgTagItem'); + const tags = [...tagsElem].map(tagEl => tagEl.textContent.trim()) + return tags +} + +togglbutton.render( + '.AgListViewTask--fk-AgListViewTask-Body:not(.toggl)', + { observe: true }, + function (elem) { + const projectElem = $('.AgSidebarCurrentProject--fk-AgSidebarContext-ProjText') + + const descriptionElem = $('.AgListViewTask--fk-AgListViewTask-Title', elem); + const link = togglbutton.createTimerLink({ + buttonType: 'minimal', + className: 'freedcamp', + projectName: projectElem?.textContent, + description: descriptionElem?.textContent, + }); + elem.appendChild(link); + } +); + + +togglbutton.render( + '.ItemViewSubheader--fk-ItemBasicFields-Title:not(.toggl)', + { observe: true }, + function (elem) { + const projectElem = $('.AgSidebarCurrentProject--fk-AgSidebarContext-ProjText') + const descriptionElem = $('.ItemViewSubheader--fk-ItemBasicFields-Title'); + const link = togglbutton.createTimerLink({ + buttonType: 'minimal', + className: 'freedcamp', + projectName: projectElem?.textContent, + description: descriptionElem?.textContent, + tags: tagsSelector + }); + elem.parentNode.insertBefore(link, elem.nextSibling); + } +); diff --git a/src/origins.js b/src/origins.js index 24d001830..bd405fd2b 100644 --- a/src/origins.js +++ b/src/origins.js @@ -196,6 +196,10 @@ export default { url: '*://*.fogbugz.com/*', name: 'Fogbugz' }, + 'freedcamp.com': { + url: '*://*.freedcamp.com/*', + name: 'Freedcamp' + }, 'freshdesk.com': { url: '*://*.freshdesk.com/*', name: 'Freshdesk' diff --git a/src/styles/style.css b/src/styles/style.css index a9c4e8d00..608746afe 100644 --- a/src/styles/style.css +++ b/src/styles/style.css @@ -1507,3 +1507,9 @@ body.notion-body.dark .toggl-button.notion { .toggl-button.linear-table { margin-top: 5px; } + + +/********* Freedcamp *********/ +.toggl-button.freedcamp { + margin-top: 5px; +}