Skip to content

Commit

Permalink
🚧 add if clauses to omit undefined messages on first run and update m…
Browse files Browse the repository at this point in the history
…anifest version
  • Loading branch information
heytulsiprasad committed Oct 6, 2020
1 parent fa56640 commit c8ee931
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
8 changes: 5 additions & 3 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ try {

// Gets pre-saved words upon start
chrome.storage.sync.get(["alertWords"], (data) => {
const alertWords = data.alertWords;
const lwrAlertWords = alertWords.map((str) => str.toLowerCase());
ALERT_WORDS = lwrAlertWords;
if (data.alertWords) {
const alertWords = data.alertWords;
const lwrAlertWords = alertWords.map((str) => str.toLowerCase());
ALERT_WORDS = lwrAlertWords;
}
});

// Listens to further changes in sync storage
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Alert Me - Google Meet",
"description": "Notify when certain words are being spoken in a meeting, your friendly reminder!",
"version": "1.0.0",
"version": "0.1.0",
"content_scripts": [{
"matches": ["https://meet.google.com/*"],
"js": ["content.js"],
Expand Down
46 changes: 24 additions & 22 deletions src/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,29 @@

// Show pre-existing status
chrome.storage.sync.get(["details"], (data) => {
const log = data.details.options;

switch (log.status) {
case "success":
footerDiv.style.backgroundColor = bgSuccess;
footerMsg.innerText = log.message;
break;
case "warning":
footerDiv.style.backgroundColor = bgWarning;
footerMsg.innerText = log.message;
break;
case "info":
footerDiv.style.backgroundColor = bgInfo;
footerMsg.innerText = log.message;
break;
case "danger":
footerDiv.style.backgroundColor = bgDanger;
footerMsg.innerText = log.message;
break;
default:
footerDiv.style.backgroundColor = bgInfo;
if (data.details) {
const log = data.details.options;

switch (log.status) {
case "success":
footerDiv.style.backgroundColor = bgSuccess;
footerMsg.innerText = log.message;
break;
case "warning":
footerDiv.style.backgroundColor = bgWarning;
footerMsg.innerText = log.message;
break;
case "info":
footerDiv.style.backgroundColor = bgInfo;
footerMsg.innerText = log.message;
break;
case "danger":
footerDiv.style.backgroundColor = bgDanger;
footerMsg.innerText = log.message;
break;
default:
footerDiv.style.backgroundColor = bgInfo;
}
}
});

Expand Down Expand Up @@ -118,7 +120,7 @@
const alertWords = data.alertWords;

// Add to DOM
addWords(alertWords);
if (alertWords) addWords(alertWords);
});

const addBtn = document.getElementById("add-btn");
Expand Down

0 comments on commit c8ee931

Please sign in to comment.