diff --git a/src/content/figma.js b/src/content/figma.js new file mode 100644 index 000000000..c2eab196b --- /dev/null +++ b/src/content/figma.js @@ -0,0 +1,34 @@ +/** + * @name Figma + * @urlAlias figma.com + * @urlRegex *://*.figma.com/* + */ +'use strict'; + +togglbutton.render( + 'div[aria-label="Main toolbar"]:not(.toggl)', + { observe: true }, + function (elem) { + const titleElem = $('span[aria-label="File name"]', elem).parentElement + const titles = [] + for (let children of titleElem.children){ + if(children.textContent.trim() !== '') titles.push(children.textContent.trim()) + // Test after file name is useless + if(children.ariaLabel === 'File name') break + } + const text = titles.join(' / ') + + const container = elem.lastChild; + + const link = togglbutton.createTimerLink({ + className: 'figma', + description: text, + buttonType: 'minimal' + }); + + if($('div[aria-label="Main toolbar"] .toggl-button.figma')){ + $('div[aria-label="Main toolbar"] .toggl-button.figma').remove() + } + container.prepend(link); + } +); diff --git a/src/origins.js b/src/origins.js index 24d001830..fdf56e9ea 100644 --- a/src/origins.js +++ b/src/origins.js @@ -188,6 +188,11 @@ export default { url: '*://*.fibery.io/*', name: 'Fibery' }, + 'figma.com': { + url: '*://*.figma.com/*', + name: 'Figma', + file: 'figma.js' + }, 'focuster.com': { url: '*://*.focuster.com/*', name: 'Focuster' @@ -709,4 +714,3 @@ export default { name: 'Zube' } }; - diff --git a/src/styles/style.css b/src/styles/style.css index a9c4e8d00..c28a0453f 100644 --- a/src/styles/style.css +++ b/src/styles/style.css @@ -1507,3 +1507,10 @@ body.notion-body.dark .toggl-button.notion { .toggl-button.linear-table { margin-top: 5px; } + + +/********* Figma *********/ +.toggl-button.figma { + margin-top: 5px; + z-index: 9999; +}