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 028fec21..bd2baff5 100644 --- a/src/wakatimeScript.ts +++ b/src/wakatimeScript.ts @@ -37,11 +37,33 @@ 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 { + category: 'Designing', + editor: 'Jupyter', + language: 'Jupyter', + project: '<>', + }; + } 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, };