Skip to content

Commit

Permalink
moved state to background
Browse files Browse the repository at this point in the history
  • Loading branch information
pathakshashank17 committed Aug 2, 2020
1 parent 7fe7047 commit 2aadeeb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
chrome.runtime.onMessage.addListener((message) => {
console.log(message);
if (message.action === "activate") {
chrome.tabs.executeScript({ file: "addBorder.js" });
} else if (message.action === "deactivate") {
chrome.tabs.executeScript({ file: "removeBorder.js" });
var isOn = false;

chrome.runtime.onMessage.addListener(({action}) => {
if (action === "toggle") {
if (isOn) {
chrome.tabs.executeScript({ file: "removeBorder.js" });
} else {
chrome.tabs.executeScript({ file: "addBorder.js" });
}
isOn = !isOn;
}
return true;
});
13 changes: 11 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@
"activeTab"
],
"background": {
"scripts": ["background.js"]
"scripts": [
"background.js"
]
},
"browser_action": {
"default_popup": "popup.html"
},
"web_accessible_resources": ["styles.css"]
"web_accessible_resources": [
"styles.css"
],
"icons": {
"16": "assets/icon.png",
"48": "assets/icon.png",
"128": "assets/icon.png"
}
}
8 changes: 1 addition & 7 deletions popup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
const button = document.getElementById("toggle");
var isON = false

button.addEventListener("click", () => {
if (!isON) {
chrome.runtime.sendMessage({ action: "activate" });
} else {
chrome.runtime.sendMessage({ action: "deactivate" });
}
isON = !isON;
chrome.runtime.sendMessage({ action: "toggle" });
});
4 changes: 2 additions & 2 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ thead,
tbody,
tfoot,
footer {
border: 1px solid #faed27 !important;
background-color: rgba(255, 255, 108, 0.217) !important;
}

div:hover,
Expand Down Expand Up @@ -67,5 +67,5 @@ thead:hover,
tbody:hover,
tfoot:hover,
footer:hover {
border: 1px solid red !important;
border: 2px solid red !important;
}

0 comments on commit 2aadeeb

Please sign in to comment.