From b65499b9aabc67834fba06b8532c4b329be60c9f Mon Sep 17 00:00:00 2001 From: Sebastian Velez Date: Tue, 11 Apr 2023 21:56:59 -0500 Subject: [PATCH 1/2] chore: add jupyter to supported online IDEs --- src/manifests/chrome.json | 2 +- src/manifests/firefox.json | 2 +- src/wakatimeScript.ts | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/manifests/chrome.json b/src/manifests/chrome.json index f5b6ed4e..f8f87956 100644 --- a/src/manifests/chrome.json +++ b/src/manifests/chrome.json @@ -33,5 +33,5 @@ "page": "options.html" }, "permissions": ["alarms", "tabs", "storage", "idle"], - "version": "3.0.10" + "version": "3.0.11" } diff --git a/src/manifests/firefox.json b/src/manifests/firefox.json index aa12d7e1..69cd5131 100644 --- a/src/manifests/firefox.json +++ b/src/manifests/firefox.json @@ -46,5 +46,5 @@ "storage", "idle" ], - "version": "3.0.10" + "version": "3.0.11" } diff --git a/src/wakatimeScript.ts b/src/wakatimeScript.ts index 2978eb1f..b23d4982 100644 --- a/src/wakatimeScript.ts +++ b/src/wakatimeScript.ts @@ -283,11 +283,32 @@ const parseFigma = (): DesignProject | undefined => { }; }; +const parseJupyter = (isDemo: boolean): DesignProject | undefined => { + const { title } = document; + if (!title.endsWith('JupyterLab') && title != 'JupyterLite') return undefined; + + try { + const projectName = + document.getElementsByClassName('f1fwtl1j')[0].children[isDemo ? 0 : 1].children[0].innerHTML; + + return { + editor: 'Jupyter', + language: 'Jupyter', + project: projectName, + }; + } catch (err: unknown) { + console.log('Error getting Jupyter project name'); + return undefined; + } +}; + const getParser: { [key: string]: | (() => { editor: string; language: string; project: string } | undefined) | undefined; } = { + 'jupyter.org': () => parseJupyter(true), + localhost: () => parseJupyter(false), 'www.canva.com': parseCanva, 'www.figma.com': parseFigma, }; From 4aaa34fd539a6166cedde7141a6b8beac58e9c90 Mon Sep 17 00:00:00 2001 From: Sebastian Velez Date: Tue, 23 May 2023 20:44:37 -0500 Subject: [PATCH 2/2] Send project:<> same as other domains for Jupyter. --- src/core/WakaTimeCore.ts | 11 ++++++++--- src/wakatimeScript.ts | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/WakaTimeCore.ts b/src/core/WakaTimeCore.ts index b39c5a44..12453c8a 100644 --- a/src/core/WakaTimeCore.ts +++ b/src/core/WakaTimeCore.ts @@ -357,9 +357,14 @@ class WakaTimeCore { getOperatingSystem(): Promise { return new Promise((resolve) => { - chrome.runtime.getPlatformInfo(function (info) { - resolve(`${info.os}_${info.arch}`); - }); + try { + chrome.runtime.getPlatformInfo(function (info) { + resolve(`${info.os}_${info.arch}`); + }); + } catch (error: unknown) { + console.log('error', error); + resolve(''); + } }); } diff --git a/src/wakatimeScript.ts b/src/wakatimeScript.ts index 2dea33fd..bd2baff5 100644 --- a/src/wakatimeScript.ts +++ b/src/wakatimeScript.ts @@ -46,9 +46,10 @@ const parseJupyter = (isDemo: boolean): DesignProject | undefined => { document.getElementsByClassName('f1fwtl1j')[0].children[isDemo ? 0 : 1].children[0].innerHTML; return { + category: 'Designing', editor: 'Jupyter', language: 'Jupyter', - project: projectName, + project: '<>', }; } catch (err: unknown) { console.log('Error getting Jupyter project name');