Skip to content

Commit

Permalink
More reliable canva project detection, fix designing category
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Aug 18, 2023
1 parent f3c1f10 commit a8a9328
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/wakatimeScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ interface DesignProject {
}

const parseCanva = (): DesignProject | undefined => {
const canvaProject = document.getElementsByClassName('rF765A');
if (canvaProject.length === 0) return;

const projectName = (document.head.querySelector('meta[property="og:title"]') as HTMLMetaElement)
.content;
if (!projectName) return;

// make sure the page title matches the design input element's value, meaning this is a design file
const canvaProjectInput = Array.from(
document.querySelector('nav')?.querySelectorAll('input') ?? [],
).find((inp) => inp.value === projectName);
if (!canvaProjectInput) return;

return {
category: 'Designing',
category: 'designing',
editor: 'Canva',
language: 'Canva Design',
project: projectName,
Expand All @@ -30,7 +35,7 @@ const parseFigma = (): DesignProject | undefined => {
const projectName = (document.querySelector('span[data-testid="filename"]') as HTMLElement)
.innerText;
return {
category: 'Designing',
category: 'designing',
editor: 'Figma',
language: 'Figma Design',
project: projectName,
Expand Down

0 comments on commit a8a9328

Please sign in to comment.