Skip to content

Commit

Permalink
feat(figma): Add figma integration
Browse files Browse the repository at this point in the history
  • Loading branch information
with-shrey committed Mar 15, 2024
1 parent 291f01c commit 57d32cb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/content/figma.js
Original file line number Diff line number Diff line change
@@ -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'
});
console.log('rerendering')
if($('div[aria-label="Main toolbar"] .toggl-button.figma')){
$('div[aria-label="Main toolbar"] .toggl-button.figma').remove()
}
container.prepend(link);
}
);
4 changes: 4 additions & 0 deletions src/origins.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ export default {
url: '*://*.fibery.io/*',
name: 'Fibery'
},
'figma.com': {
url: '*://*.figma.io/*',
name: 'Figma'
},
'focuster.com': {
url: '*://*.focuster.com/*',
name: 'Focuster'
Expand Down

0 comments on commit 57d32cb

Please sign in to comment.