diff --git a/background.js b/background.js index 6b1ddaf..1293784 100644 --- a/background.js +++ b/background.js @@ -8,6 +8,7 @@ browserOrChrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { if (changeInfo.status == 'complete' && tab.url) { const matches = tab.url.match(/\.com\/([0-9]{4})\/day\/([0-9]+)(\/answer)?/); + //const matches = tab.url.match(/file:\/\/\//) ? [, 2022, 3, '/answer'] : undefined; if (matches) { const [, year, day, answer] = matches; if (!answer) { diff --git a/content.js b/content.js index 548e8e3..a12c1b2 100644 --- a/content.js +++ b/content.js @@ -42,7 +42,7 @@ const onGetStopData = (sendResponse) => { return; } - const part = (document.getElementsByClassName('share') === null ? 1 : 2); + const part = (document.getElementsByClassName('share').length === 0 ? 1 : 2); sendResponse({ userName, part }); }; @@ -54,5 +54,5 @@ const getUserName = () => { return undefined; } - return element.textContent.trim(); + return element.firstChild.textContent.trim(); };