Skip to content

Commit

Permalink
Setting Initial values for the checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
vk-44 committed Apr 11, 2024
1 parent 33982dd commit 8fc8d09
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
//Setting all the checkbox values to true when the extension is newly installed
chrome.runtime.onInstalled.addListener(() => {
const checkboxValues = {
signin: true,
ads: true,
promoted: true,
related: true,
};

chrome.storage.local.set({ checkboxValues });
});

//Listen for messages from content scripts
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "getData") {
//Returns the Object from chrome's local storage
if (request.action === "getObj") {
chrome.storage.local
.get(["checkboxValues"])
.then((res) => sendResponse(res.checkboxValues));
Expand All @@ -9,7 +22,8 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
return true;
}

if (request.action === "modifyUrl") {
//Modifies the URL with newURL
if (request.action === "modifyURL") {
chrome.tabs.update(sender.tab.id, { url: request.newURL });
}
});

0 comments on commit 8fc8d09

Please sign in to comment.