Skip to content

Added cross-browser compatibility for gekko and blink based browsers #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"96": "icons/icon.png",
"48": "icons/icon.png"
},
"background": {
"service_worker": "scripts/background.js"
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "109.0"
}
},
"content_scripts": [
{
Expand All @@ -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"
]
}
],

Expand Down
1 change: 1 addition & 0 deletions src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ <h4 class="font-semibold text-xl">Note:</h4>
</div>
</div>
</div>
<script src="scripts/browser-polyfill.js"></script>
<script src="scripts/jquery-3.2.1.min.js"></script>
<script type="text/javascript" type="text/javascript" src="materialize/js/materialize.min.js"></script>
<script src="scripts/main.js"></script>
Expand Down
Empty file removed src/scripts/background.js
Empty file.
4 changes: 4 additions & 0 deletions src/scripts/browser-polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// scripts/browser-polyfill.js
if (typeof browser === "undefined") {
window.browser = typeof chrome !== "undefined" ? chrome : {};
}
43 changes: 21 additions & 22 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -102,7 +102,7 @@ document.getElementById('refreshCache').addEventListener('click', async (e) => {
});

// 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) {
Expand All @@ -116,16 +116,16 @@ document.getElementById('refreshCache').addEventListener('click', async (e) => {
});

function handleEnableChange() {
let value = enableToggleElement.checked;
chrome.storage.local.set({ enableToggle: value });
var value = enableToggleElement.checked;
browser.storage.local.set({ enableToggle: value });
}
function handleStartingDateChange() {
let value = startingDateElement.value;
chrome.storage.local.set({ startingDate: value });
var value = startingDateElement.value;
browser.storage.local.set({ startingDate: value });
}
function handleEndingDateChange() {
let value = endingDateElement.value;
chrome.storage.local.set({ endingDate: value });
var value = endingDateElement.value;
browser.storage.local.set({ endingDate: value });
}
function handleLastWeekContributionChange() {
let value = lastWeekContributionElement.checked;
Expand All @@ -145,8 +145,7 @@ function handleLastWeekContributionChange() {
labelElement.classList.add("unselectedLabel");
labelElement.classList.remove("selectedLabel");
}

chrome.storage.local.set({ lastWeekContribution: value });
browser.storage.local.set({ lastWeekContribution: value });
}

function handleYesterdayContributionChange() {
Expand All @@ -168,7 +167,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() {
Expand Down Expand Up @@ -215,20 +214,20 @@ function getToday() {
}

function handleGithubUsernameChange() {
let value = githubUsernameElement.value;
chrome.storage.local.set({ githubUsername: value });
var value = githubUsernameElement.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 });
var value = projectNameElement.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;
Expand All @@ -242,17 +241,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 });
var value = userReasonElement.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);
Expand All @@ -267,4 +266,4 @@ lastWeekContributionElement.addEventListener('change', handleLastWeekContributio
yesterdayContributionElement.addEventListener('change', handleYesterdayContributionChange);
showOpenLabelElement.addEventListener('change', handleOpenLabelChange);
userReasonElement.addEventListener('keyup', handleUserReasonChange);
document.addEventListener('DOMContentLoaded', handleBodyOnLoad);
document.addEventListener('DOMContentLoaded', handleBodyOnLoad);
Loading