-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7eda33
commit bd74295
Showing
4 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"name": "Chameleon Dynamic Theme", | ||
"permissions": [ | ||
"tabs", | ||
"storage", | ||
"<all_urls>", | ||
"theme" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
var configData = { | ||
enableBorder : false, | ||
toolbarHighlight : false | ||
} | ||
|
||
function checkStoredSettings(item) { | ||
|
||
console.log("Storage:" + JSON.stringify(item)); | ||
|
||
if (!item.configData) { | ||
console.log("Setting config first time...") | ||
browser.storage.local.set({configData}); | ||
} else { | ||
console.log("Config exists in storage...") | ||
configData = item.configData; | ||
} | ||
|
||
if(configData.enableBorder) { | ||
console.log('Trying to mark checked in the DOM ') | ||
document.querySelector('#config_immersion').setAttribute('checked',configData.enableBorder); | ||
} else { | ||
console.log('Trying to uncheck ') | ||
document.querySelector('#config_immersion').removeAttribute('checked'); | ||
} | ||
} | ||
|
||
function onError(error) { | ||
console.log(`Error: ${error}`); | ||
} | ||
|
||
var gettingItem = browser.storage.local.get(); | ||
gettingItem.then(checkStoredSettings, onError); | ||
|
||
function updateSettings(e) { | ||
let immersionSetting = e.target.checked; | ||
console.log(immersionSetting); | ||
configData.enableBorder = immersionSetting; | ||
browser.storage.local.set({configData}); | ||
|
||
var metaData = { | ||
kind : 'refresh' | ||
} | ||
|
||
browser.runtime.sendMessage(metaData); | ||
|
||
} | ||
|
||
document.addEventListener('DOMContentLoaded',function() { | ||
document.querySelector('#config_immersion').onchange=updateSettings; | ||
|
||
|
||
},false); |