diff --git a/package.json b/package.json
index 9262264..505845b 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"tailwindcss": "^4.1.4"
},
"dependencies": {
- "@tailwindcss/cli": "^4.1.3"
+ "@tailwindcss/cli": "^4.1.3",
+ "browser-polyfill": "^3.20.2"
}
-}
\ No newline at end of file
+}
diff --git a/src/manifest.json b/src/manifest.json
index 69eaa16..5565687 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -11,8 +11,11 @@
"96": "icons/icon.png",
"48": "icons/icon.png"
},
- "background": {
- "service_worker": "scripts/background.js"
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "scrum-helper@fossasia.org",
+ "strict_min_version": "109.0"
+ }
},
"content_scripts": [
{
@@ -25,7 +28,12 @@
"*://outlook.office.com/*",
"*://mail.yahoo.com/*"
],
- "js": ["scripts/jquery-3.2.1.min.js", "scripts/emailClientAdapter.js", "scripts/scrumHelper.js"]
+ "js": [
+ "scripts/browser-polyfill.js",
+ "scripts/jquery-3.2.1.min.js",
+ "scripts/emailClientAdapter.js",
+ "scripts/scrumHelper.js"
+ ]
}
],
diff --git a/src/popup.html b/src/popup.html
index 59753de..fb9f5c5 100644
--- a/src/popup.html
+++ b/src/popup.html
@@ -271,6 +271,7 @@
Note:
+
diff --git a/src/scripts/background.js b/src/scripts/background.js
deleted file mode 100644
index e69de29..0000000
diff --git a/src/scripts/browser-polyfill.js b/src/scripts/browser-polyfill.js
new file mode 100644
index 0000000..5bb0652
--- /dev/null
+++ b/src/scripts/browser-polyfill.js
@@ -0,0 +1,7 @@
+if (typeof browser === "undefined") {
+ window.browser = typeof chrome !== "undefined" ? chrome : {};
+ // Create global browser reference
+ if (typeof chrome !== "undefined") {
+ var browser = chrome;
+ }
+}
diff --git a/src/scripts/main.js b/src/scripts/main.js
index 383e6e2..2c58f1f 100644
--- a/src/scripts/main.js
+++ b/src/scripts/main.js
@@ -12,7 +12,7 @@ let userReasonElement = document.getElementById('userReason');
let showCommitsElement = document.getElementById('showCommits');
function handleBodyOnLoad() {
- chrome.storage.local.get(
+ browser.storage.local.get(
[
'githubUsername',
'projectName',
@@ -43,7 +43,6 @@ function handleBodyOnLoad() {
if (items.enableToggle) {
enableToggleElement.checked = items.enableToggle;
} else if (items.enableToggle !== false) {
- // undefined
enableToggleElement.checked = true;
handleEnableChange();
}
@@ -56,7 +55,6 @@ function handleBodyOnLoad() {
if (items.showOpenLabel) {
showOpenLabelElement.checked = items.showOpenLabel;
} else if (items.showOpenLabel !== false) {
- // undefined
showOpenLabelElement.checked = true;
handleOpenLabelChange();
}
@@ -79,7 +77,7 @@ function handleBodyOnLoad() {
yesterdayContributionElement.checked = true;
handleYesterdayContributionChange();
}
- if (items.showCommits){
+ if (items.showCommits) {
showCommitsElement.checked = items.showCommits;
} else {
showCommitsElement.checked = false;
@@ -95,14 +93,13 @@ document.getElementById('refreshCache').addEventListener('click', async (e) => {
button.disabled = true;
try {
- const tabs = await chrome.tabs.query({ active: true, currentWindow: true });
- await chrome.tabs.sendMessage(tabs[0].id, {
+ const tabs = await browser.tabs.query({ active: true, currentWindow: true });
+ await browser.tabs.sendMessage(tabs[0].id, {
action: 'forceRefresh',
timestamp: Date.now()
});
- // Reload the active tab to re-inject content
- chrome.tabs.reload(tabs[0].id);
+ browser.tabs.reload(tabs[0].id);
Materialize.toast({ html: 'Data refreshed successfully!', classes: 'green' });
} catch (err) {
@@ -117,15 +114,15 @@ document.getElementById('refreshCache').addEventListener('click', async (e) => {
function handleEnableChange() {
let value = enableToggleElement.checked;
- chrome.storage.local.set({ enableToggle: value });
+ browser.storage.local.set({ enableToggle: value });
}
function handleStartingDateChange() {
let value = startingDateElement.value;
- chrome.storage.local.set({ startingDate: value });
+ browser.storage.local.set({ startingDate: value });
}
function handleEndingDateChange() {
let value = endingDateElement.value;
- chrome.storage.local.set({ endingDate: value });
+ browser.storage.local.set({ endingDate: value });
}
function handleLastWeekContributionChange() {
let value = lastWeekContributionElement.checked;
@@ -146,7 +143,7 @@ function handleLastWeekContributionChange() {
labelElement.classList.remove("selectedLabel");
}
- chrome.storage.local.set({ lastWeekContribution: value });
+ browser.storage.local.set({ lastWeekContribution: value });
}
function handleYesterdayContributionChange() {
@@ -168,7 +165,7 @@ function handleYesterdayContributionChange() {
labelElement.classList.add("unselectedLabel");
labelElement.classList.remove("selectedLabel");
}
- chrome.storage.local.set({ yesterdayContribution: value });
+ browser.storage.local.set({ yesterdayContribution: value });
}
function getLastWeek() {
@@ -216,19 +213,19 @@ function getToday() {
function handleGithubUsernameChange() {
let value = githubUsernameElement.value;
- chrome.storage.local.set({ githubUsername: value });
+ browser.storage.local.set({ githubUsername: value });
}
function handleGithubTokenChange() {
let value = githubTokenElement.value;
- chrome.storage.local.set({ githubToken: value });
+ browser.storage.local.set({ githubToken: value });
}
function handleProjectNameChange() {
let value = projectNameElement.value;
- chrome.storage.local.set({ projectName: value });
+ browser.storage.local.set({ projectName: value });
}
function handleCacheInputChange() {
let value = cacheInputElement.value;
- chrome.storage.local.set({ cacheInput: value });
+ browser.storage.local.set({ cacheInput: value });
}
function handleOpenLabelChange() {
let value = showOpenLabelElement.checked;
@@ -242,17 +239,17 @@ function handleOpenLabelChange() {
labelElement.classList.remove("selectedLabel");
}
- chrome.storage.local.set({ showOpenLabel: value });
+ browser.storage.local.set({ showOpenLabel: value });
}
function handleUserReasonChange() {
let value = userReasonElement.value;
- chrome.storage.local.set({ userReason: value });
+ browser.storage.local.set({ userReason: value });
}
function handleShowCommitsChange() {
let value = showCommitsElement.checked;
- chrome.storage.local.set({ showCommits: value });
+ browser.storage.local.set({ showCommits: value });
}
enableToggleElement.addEventListener('change', handleEnableChange);
diff --git a/src/scripts/popup.js b/src/scripts/popup.js
index b45a888..73684a6 100644
--- a/src/scripts/popup.js
+++ b/src/scripts/popup.js
@@ -43,6 +43,9 @@ function getYesterday() {
}
document.addEventListener('DOMContentLoaded', function () {
+ // Cross-browser storage detection
+ const storage = typeof browser !== 'undefined' ? browser.storage : chrome.storage;
+
// Dark mode setup
const darkModeToggle = document.querySelector('img[alt="Night Mode"]');
const settingsIcon = document.getElementById('settingsIcon');
@@ -62,12 +65,12 @@ document.addEventListener('DOMContentLoaded', function () {
const orgInput = document.getElementById('orgInput');
const setOrgBtn = document.getElementById('setOrgBtn');
- chrome.storage.local.get(['darkMode'], function (result) {
+ storage.local.get(['darkMode'], function (result) {
if (result.darkMode) {
body.classList.add('dark-mode');
darkModeToggle.src = 'icons/light-mode.png';
if (settingsIcon) {
- settingsIcon.src = 'icons/settings-night.png'; // Changed from settings-night.png
+ settingsIcon.src = 'icons/settings-night.png';
}
}
});
@@ -87,7 +90,7 @@ document.addEventListener('DOMContentLoaded', function () {
darkModeToggle.addEventListener('click', function () {
body.classList.toggle('dark-mode');
const isDarkMode = body.classList.contains('dark-mode');
- chrome.storage.local.set({ darkMode: isDarkMode });
+ storage.local.set({ darkMode: isDarkMode });
this.src = isDarkMode ? 'icons/light-mode.png' : 'icons/night-mode.png';
const settingsIcon = document.getElementById('settingsIcon');
if (settingsIcon) {
@@ -129,7 +132,6 @@ document.addEventListener('DOMContentLoaded', function () {
'githubToken',
'projectName',
'settingsToggle',
-
];
const radios = document.querySelectorAll('input[name="timeframe"]');
@@ -163,7 +165,6 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
-
if (customDateContainer) {
if (!enableToggle) {
customDateContainer.style.opacity = '0.5';
@@ -188,7 +189,7 @@ document.addEventListener('DOMContentLoaded', function () {
}
}
- chrome.storage.local.get(['enableToggle'], (items) => {
+ storage.local.get(['enableToggle'], (items) => {
const enableToggle = items.enableToggle !== false;
updateContentState(enableToggle);
if (!enableToggle) {
@@ -198,18 +199,16 @@ document.addEventListener('DOMContentLoaded', function () {
initializePopup();
})
- chrome.storage.onChanged.addListener((changes, namespace) => {
+ storage.onChanged.addListener((changes, namespace) => {
if (namespace === 'local' && changes.enableToggle) {
updateContentState(changes.enableToggle.newValue);
if (changes.enableToggle.newValue) {
- // re-initialize if enabled
initializePopup();
}
}
});
function initializePopup() {
-
// Button setup
const generateBtn = document.getElementById('generateReport');
const copyBtn = document.getElementById('copyReport');
@@ -217,8 +216,10 @@ document.addEventListener('DOMContentLoaded', function () {
generateBtn.addEventListener('click', function () {
// Check org input value before generating report
let org = orgInput.value.trim().toLowerCase();
- // Allow empty org to fetch all GitHub activities
- chrome.storage.local.set({ orgName: org }, () => {
+ if (!org) {
+ org = 'fossasia';
+ }
+ storage.local.set({ orgName: org }, () => {
generateBtn.innerHTML = ' Generating...';
generateBtn.disabled = true;
window.generateScrumReport();
@@ -265,14 +266,14 @@ document.addEventListener('DOMContentLoaded', function () {
startDateInput.readOnly = false;
endDateInput.readOnly = false;
- chrome.storage.local.set({
+ storage.local.set({
lastWeekContribution: false,
yesterdayContribution: false,
selectedTimeframe: null
});
});
- chrome.storage.local.get([
+ storage.local.get([
'selectedTimeframe',
'lastWeekContribution',
'yesterdayContribution',
@@ -281,13 +282,11 @@ document.addEventListener('DOMContentLoaded', function () {
], (items) => {
console.log('Restoring state:', items);
-
if (items.startingDate && items.endingDate && !items.lastWeekContribution && !items.yesterdayContribution) {
const startDateInput = document.getElementById('startingDate');
const endDateInput = document.getElementById('endingDate');
if (startDateInput && endDateInput) {
-
startDateInput.value = items.startingDate;
endDateInput.value = items.endingDate;
startDateInput.readOnly = false;
@@ -323,7 +322,7 @@ document.addEventListener('DOMContentLoaded', function () {
}
startDateInput.readOnly = endDateInput.readOnly = true;
- chrome.storage.local.set({
+ storage.local.set({
startingDate: startDateInput.value,
endingDate: endDateInput.value,
lastWeekContribution: items.selectedTimeframe === 'lastWeekContribution',
@@ -370,16 +369,18 @@ document.addEventListener('DOMContentLoaded', function () {
showReportView();
// Load org from storage or default
- chrome.storage.local.get(['orgName'], function (result) {
+ storage.local.get(['orgName'], function (result) {
orgInput.value = result.orgName || '';
});
// Auto-update orgName in storage on input change
orgInput.addEventListener('input', function () {
let org = orgInput.value.trim().toLowerCase();
- // Allow empty org to fetch all GitHub activities
- chrome.storage.local.set({ orgName: org }, function () {
- chrome.storage.local.remove('githubCache'); // Clear cache on org change
+ if (!org) {
+ org = 'fossasia';
+ }
+ storage.local.set({ orgName: org }, function () {
+ storage.local.remove('githubCache');
});
});
@@ -432,15 +433,14 @@ document.addEventListener('DOMContentLoaded', function () {
}
const oldToast = document.getElementById('invalid-org-toast');
if (oldToast) oldToast.parentNode.removeChild(oldToast);
-
- chrome.storage.local.set({ orgName: org }, function () {
+ storage.local.set({ orgName: org }, function () {
// Always clear the scrum report and show org changed message
const scrumReport = document.getElementById('scrumReport');
if (scrumReport) {
scrumReport.innerHTML = 'Organization changed. Click Generate button to fetch the GitHub activities.
';
}
// Clear the githubCache for previous org
- chrome.storage.local.remove('githubCache');
+ storage.local.remove('githubCache');
setOrgBtn.disabled = false;
setOrgBtn.innerHTML = originalText;
// Always show green toast: org is set
@@ -493,7 +493,7 @@ document.addEventListener('DOMContentLoaded', function () {
let cacheInput = document.getElementById('cacheInput');
if (cacheInput) {
- chrome.storage.local.get(['cacheInput'], function (result) {
+ storage.local.get(['cacheInput'], function (result) {
if (result.cacheInput) {
cacheInput.value = result.cacheInput;
} else {
@@ -515,15 +515,12 @@ document.addEventListener('DOMContentLoaded', function () {
this.style.borderColor = '#10b981';
}
- chrome.storage.local.set({ cacheInput: ttlValue }, function () {
+ storage.local.set({ cacheInput: ttlValue }, function () {
console.log('Cache TTL saved:', ttlValue, 'minutes');
});
});
-
}
-});
-
// Tooltip bubble
document.querySelectorAll('.tooltip-container').forEach(container => {
const bubble = container.querySelector('.tooltip-bubble');
@@ -576,7 +573,7 @@ document.querySelectorAll('input[name="timeframe"]').forEach(radio => {
startDateInput.readOnly = false;
endDateInput.readOnly = false;
- chrome.storage.local.set({
+ storage.local.set({
lastWeekContribution: false,
yesterdayContribution: false,
selectedTimeframe: null
@@ -646,7 +643,7 @@ function toggleRadio(radio) {
startDateInput.readOnly = endDateInput.readOnly = true;
- chrome.storage.local.set({
+ storage.local.set({
startingDate: startDateInput.value,
endingDate: endDateInput.value,
lastWeekContribution: radio.id === 'lastWeekContribution',
@@ -660,5 +657,4 @@ function toggleRadio(radio) {
isLastWeek: radio.id === 'lastWeekContribution'
});
});
-}
-
+}});
diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js
index b6c92b3..2f62207 100644
--- a/src/scripts/scrumHelper.js
+++ b/src/scripts/scrumHelper.js
@@ -1,4 +1,21 @@
const DEBUG = true;
+// Unified browser storage API using polyfilled browser object
+const {storage} = browser;
+const runtime = {browser};
+
+// Unified storage functions
+function storageGet(keys) {
+ return new Promise(resolve => browser.storage.local.get(keys, resolve));
+}
+
+function storageSet(items) {
+ return new Promise(resolve => browser.storage.local.set(items, resolve));
+}
+
+function storageRemove(keys) {
+ return new Promise(resolve => browser.storage.local.remove(keys, resolve));
+}
+
function log(...args) {
if (DEBUG) {
console.log(`[SCRUM-HELPER]:`, ...args);
@@ -23,8 +40,9 @@ function allIncluded(outputTarget = 'email') {
return;
}
scrumGenerationInProgress = true;
- console.log('allIncluded called with outputTarget:', outputTarget);
- console.log('Current window context:', window.location.href);
+ log('allIncluded called with outputTarget:', outputTarget);
+ log('Current window context:', window.location.href);
+
let scrumBody = null;
let scrumSubject = null;
let startingDate = '';
@@ -61,31 +79,26 @@ function allIncluded(outputTarget = 'email') {
let issue_opened_button =
'open
';
-
- // let linkStyle = '';
- function getChromeData() {
- console.log("Getting Chrome data for context:", outputTarget);
- chrome.storage.local.get(
- [
- 'githubUsername',
- 'githubToken',
- 'projectName',
- 'enableToggle',
- 'startingDate',
- 'endingDate',
- 'showOpenLabel',
- 'showClosedLabel',
- 'lastWeekContribution',
- 'yesterdayContribution',
- 'userReason',
- 'showCommits',
- 'githubCache',
- 'cacheInput',
- 'orgName'
- ],
- (items) => {
- console.log("Storage items received:", items);
-
+ async function getStorageData() {
+ log("Getting storage data for context:", outputTarget);
+ const items = await storageGet([
+ 'githubUsername',
+ 'githubToken',
+ 'projectName',
+ 'enableToggle',
+ 'startingDate',
+ 'endingDate',
+ 'showOpenLabel',
+ 'showClosedLabel',
+ 'lastWeekContribution',
+ 'yesterdayContribution',
+ 'userReason',
+ 'showCommits',
+ 'githubCache',
+ 'cacheInput',
+ 'orgName'
+ ]);
+ log("Storage items received:", items);
if (outputTarget === 'popup') {
const usernameFromDOM = document.getElementById('githubUsername')?.value;
@@ -98,7 +111,7 @@ function allIncluded(outputTarget = 'email') {
items.userReason = reasonFromDOM || items.userReason;
items.githubToken = tokenFromDOM || items.githubToken;
- chrome.storage.local.set({
+ await storageSet({
githubUsername: items.githubUsername,
projectName: items.projectName,
userReason: items.userReason,
@@ -125,18 +138,17 @@ function allIncluded(outputTarget = 'email') {
startingDate = items.startingDate;
endingDate = items.endingDate;
} else {
- handleLastWeekContributionChange(); //on fresh unpack - default to last week.
+ handleLastWeekContributionChange();
if (outputTarget === 'popup') {
- chrome.storage.local.set({ lastWeekContribution: true, yesterdayContribution: false });
+ await storageSet({ lastWeekContribution: true, yesterdayContribution: false });
}
}
if (githubUsername) {
- console.log("About to fetch GitHub data for:", githubUsername);
+ log("About to fetch GitHub data for:", githubUsername);
fetchGithubData();
} else {
if (outputTarget === 'popup') {
- console.log("No username found - popup context");
- // Show error in popup
+ log("No username found - popup context");
const scrumReport = document.getElementById('scrumReport');
const generateBtn = document.getElementById('generateReport');
if (scrumReport) {
@@ -148,7 +160,7 @@ function allIncluded(outputTarget = 'email') {
}
scrumGenerationInProgress = false;
} else {
- console.warn('No GitHub username found in storage');
+ logError('No GitHub username found in storage');
scrumGenerationInProgress = false;
}
return;
@@ -159,13 +171,12 @@ function allIncluded(outputTarget = 'email') {
if (items.showCommits !== undefined) {
showCommits = items.showCommits;
} else {
- showCommits = false; // Default value
+ showCommits = false;
}
-
if (!items.showOpenLabel) {
showOpenLabel = false;
- pr_unmerged_button = '';
+ pr_open_button = '';
issue_opened_button = '';
pr_merged_button = '';
issue_closed_button = '';
@@ -181,10 +192,8 @@ function allIncluded(outputTarget = 'email') {
orgName = items.orgName || '';
console.log('[SCRUM-HELPER] orgName set to:', orgName);
}
- },
- );
- }
- getChromeData();
+ }
+ getStorageData();
function handleLastWeekContributionChange() {
endingDate = getToday();
@@ -251,16 +260,12 @@ function allIncluded(outputTarget = 'email') {
};
async function getCacheTTL() {
- return new Promise((resolve) => {
- chrome.storage.local.get(['cacheInput'], function (result) {
- const ttlMinutes = result.cacheInput || 10;
- resolve(ttlMinutes * 60 * 1000);
- });
- });
+ const result = await storageGet(['cacheInput']);
+ const ttlMinutes = result.cacheInput || 10;
+ return ttlMinutes * 60 * 1000;
}
-
- function saveToStorage(data, subject = null) {
+ async function saveToStorage(data, subject = null) {
const cacheData = {
data: data,
cacheKey: githubCache.cacheKey,
@@ -275,57 +280,55 @@ function allIncluded(outputTarget = 'email') {
org: orgName,
});
- return new Promise((resolve) => {
- chrome.storage.local.set({ githubCache: cacheData }, () => {
- if (chrome.runtime.lastError) {
- logError('Storage save failed: ', chrome.runtime.lastError);
- resolve(false);
- } else {
- log('Cache saved successfuly');
- githubCache.data = data;
- githubCache.subject = subject;
- resolve(true);
- }
- });
- });
+ try {
+ await storageSet({ githubCache: cacheData });
+ log('Cache saved successfully');
+ githubCache.data = data;
+ githubCache.subject = subject;
+ return true;
+ } catch (err) {
+ logError('Storage save failed: ', err);
+ return false;
+ }
}
- function loadFromStorage() {
+ async function loadFromStorage() {
log('Loading cache from storage');
- return new Promise(async (resolve) => {
+ try {
+ const result = await storageGet('githubCache');
+ const cache = result.githubCache;
+ if (!cache) {
+ log('No cache found in storage');
+ return false;
+ }
+
const currentTTL = await getCacheTTL();
- chrome.storage.local.get('githubCache', (result) => {
- const cache = result.githubCache;
- if (!cache) {
- log('No cache found in storage');
- resolve(false);
- return;
- }
- const isCacheExpired = (Date.now() - cache.timestamp) > currentTTL;
- if (isCacheExpired) {
- log('Cached data is expired');
- resolve(false);
- return;
- }
- log('Found valid cache:', {
- cacheKey: cache.cacheKey,
- age: `${((Date.now() - cache.timestamp) / 1000 / 60).toFixed(1)} minutes`,
- });
-
- githubCache.data = cache.data;
- githubCache.cacheKey = cache.cacheKey;
- githubCache.timestamp = cache.timestamp;
- githubCache.subject = cache.subject;
- githubCache.usedToken = cache.usedToken || false;
+ const isCacheExpired = (Date.now() - cache.timestamp) > currentTTL;
+ if (isCacheExpired) {
+ log('Cached data is expired');
+ return false;
+ }
+
+ log('Found valid cache:', {
+ cacheKey: cache.cacheKey,
+ age: `${((Date.now() - cache.timestamp) / 1000 / 60).toFixed(1)} minutes`,
+ });
+ githubCache.data = cache.data;
+ githubCache.cacheKey = cache.cacheKey;
+ githubCache.timestamp = cache.timestamp;
+ githubCache.subject = cache.subject;
+ githubCache.usedToken = cache.usedToken || false;
- if (cache.subject && scrumSubject) {
- scrumSubject.value = cache.subject;
- scrumSubject.dispatchEvent(new Event('input', { bubbles: true }));
- }
- resolve(true);
- });
- });
+ if (cache.subject && scrumSubject) {
+ scrumSubject.value = cache.subject;
+ scrumSubject.dispatchEvent(new Event('input', { bubbles: true }));
+ }
+ return true;
+ } catch (err) {
+ logError('Error loading from storage:', err);
+ return false;
+ }
}
async function fetchGithubData() {
@@ -350,7 +353,7 @@ function allIncluded(outputTarget = 'email') {
// Check if we need to load from storage
if (!githubCache.data && !githubCache.fetching) {
await loadFromStorage();
- };
+ }
const currentTTL = await getCacheTTL();
githubCache.ttl = currentTTL;
@@ -361,7 +364,7 @@ function allIncluded(outputTarget = 'email') {
const isCacheKeyMatch = githubCache.cacheKey === cacheKey;
const needsToken = !!githubToken;
const cacheUsedToken = !!githubCache.usedToken;
- if (githubCache.data && isCacheFresh && isCacheKeyMatch) {
+ if (githubCache.data && isCacheFresh && isCacheKeyMatch) {
if (needsToken && !cacheUsedToken) {
log('Cache was fetched without token, but user now has a token. Invalidating cache.');
githubCache.data = null;
@@ -433,8 +436,8 @@ function allIncluded(outputTarget = 'email') {
}
if (issuesRes.status === 404 || prRes.status === 404) {
- if (outputTarget === 'popup') {
- Materialize.toast && Materialize.toast('Organization not found on GitHub', 3000);
+ if (outputTarget === 'popup' && typeof Materialize !== 'undefined' && Materialize.toast) {
+ Materialize.toast('Organization not found on GitHub', 3000);
}
throw new Error('Organization not found');
}
@@ -485,6 +488,7 @@ function allIncluded(outputTarget = 'email') {
if (outputTarget === 'popup') {
const generateBtn = document.getElementById('generateReport');
+ const scrumReport = document.getElementById('scrumReport');
if (scrumReport) {
let errorMsg = 'An error occurred while generating the report.';
if (err) {
@@ -493,8 +497,6 @@ function allIncluded(outputTarget = 'email') {
else errorMsg = JSON.stringify(err)
}
scrumReport.innerHTML = `${err.message || 'An error occurred while generating the report.'}
`;
- generateBtn.innerHTML = ' Generate Report';
- generateBtn.disabled = false;
}
if (generateBtn) {
generateBtn.innerHTML = ' Generate Report';
@@ -534,7 +536,6 @@ function allIncluded(outputTarget = 'email') {
}
}
}
-
}`;
}).join('\n');
const query = `query { ${queries} }`;
@@ -570,6 +571,7 @@ function allIncluded(outputTarget = 'email') {
});
return commitMap;
}
+
async function verifyCacheStatus() {
log('Cache Status: ', {
hasCachedData: !!githubCache.data,
@@ -578,9 +580,7 @@ function allIncluded(outputTarget = 'email') {
isFetching: githubCache.fetching,
queueLength: githubCache.queue.length
});
- const storageData = await new Promise(resolve => {
- chrome.storage.local.get('githubCache', resolve);
- });
+ const storageData = await storageGet('githubCache');
log('Storage Status:', {
hasStoredData: !!storageData.githubCache,
storedCacheKey: storageData.githubCache?.cacheKey,
@@ -969,13 +969,8 @@ ${userReason}`;
const hasCommitsInRange = showCommits && item._allCommits && item._allCommits.length > 0;
if (!hasCommitsInRange) {
-
- continue; //skip these prs - created outside daterange with no commits
- } else {
-
+ continue;
}
- } else {
-
}
const prAction = isNewPR ? 'Made PR' : 'Existing PR';
if (isDraft) {
@@ -1130,14 +1125,10 @@ ${userReason}`;
async function forceGithubDataRefresh() {
let showCommits = false;
- await new Promise(resolve => {
- chrome.storage.local.get('showCommits', (result) => {
- if (result.showCommits !== undefined) {
- showCommits = result.showCommits;
- }
- resolve();
- });
- });
+ const result = await storageGet('showCommits');
+ if (result.showCommits !== undefined) {
+ showCommits = result.showCommits;
+ }
if (typeof githubCache !== 'undefined') {
githubCache.data = null;
@@ -1148,11 +1139,8 @@ async function forceGithubDataRefresh() {
githubCache.queue = [];
}
- await new Promise(resolve => {
- chrome.storage.local.remove('githubCache', resolve);
- });
-
- chrome.storage.local.set({ showCommits: showCommits });
+ await storageRemove('githubCache');
+ await storageSet({ showCommits: showCommits });
hasInjectedContent = false;
@@ -1165,8 +1153,10 @@ async function forceGithubDataRefresh() {
if (window.location.protocol.startsWith('http')) {
allIncluded('email');
- $('button>span:contains(New conversation)').parent('button').click(() => {
- allIncluded();
+ document.querySelectorAll('button').forEach(button => {
+ if (button.textContent.includes() === 'New conversation' && button.closest('.conversation-toolbar')) {
+ button.addEventListener('click', () => allIncluded());
+ }
});
}
@@ -1174,7 +1164,7 @@ window.generateScrumReport = function () {
allIncluded('popup');
}
-chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
+runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'forceRefresh') {
forceGithubDataRefresh()
.then(result => sendResponse(result)).catch(err => {