Browse Source

updated storage function to fit chrome

dev
Kyle Mitchell 2 years ago
parent
commit
f8e0f2337f
2 changed files with 13 additions and 18 deletions
  1. +5
    -10
      js/home.js
  2. +8
    -8
      js/options.js

+ 5
- 10
js/home.js View File

@@ -1,5 +1,5 @@
function restore_options() {
browser.storage.sync.get("links", function(result){
chrome.storage.sync.get("links", function(result){
var quads = document.querySelectorAll('a')
for (i = 0; i < quads.length; i++) {
if (result.links[i]) {
@@ -9,7 +9,7 @@ function restore_options() {
}
}
})
browser.storage.sync.get("colors", function(result){
chrome.storage.sync.get("colors", function(result){
var quads = document.querySelectorAll('a')
var style = document.createElement('style');
for (i = 0; i < quads.length; i++) {
@@ -19,14 +19,9 @@ function restore_options() {
)
}
}
document.head.appendChild(style);
for (i = 0; i < input_colors.length; i++) {
if (result.links[i]) {
input_colors[i].value = result.colors[i]
}
}
document.head.appendChild(style)
})
browser.storage.sync.get("mode", function(result){
chrome.storage.sync.get("mode", function(result){
if (result.mode) {
switch(result.mode) {
case "light":
@@ -40,7 +35,7 @@ function restore_options() {
}
} else {
mode = "light"
browser.storage.sync.set({mode:"light"})
chrome.storage.sync.set({mode:"light"})
}
})
}


+ 8
- 8
js/options.js View File

@@ -13,12 +13,12 @@ function save_options() {
links.push(input_links[i].value)
colors.push(input_colors[i].value)
}
browser.storage.sync.set({links:links, colors:colors})
chrome.storage.sync.set({links:links, colors:colors})
console.log("Settings Saved ")
}
function restore_options() {
var mode
browser.storage.sync.get("mode", function(result){
chrome.storage.sync.get("mode", function(result){
if (result.mode) {
switch(result.mode) {
case "light":
@@ -32,17 +32,17 @@ function restore_options() {
}
} else {
mode = "light"
browser.storage.sync.set({mode:"light"})
chrome.storage.sync.set({mode:"light"})
save_options()
}
})
browser.storage.sync.get("links", function(result){
chrome.storage.sync.get("links", function(result){
var input_links = document.querySelectorAll('input[type="text"]')
for (i = 0; i < input_links.length; i++) {
input_links[i].value = result.links[i]
}
})
browser.storage.sync.get("colors", function(result){
chrome.storage.sync.get("colors", function(result){
var input_colors = document.querySelectorAll('input[type="color"]')
for (i = 0; i < input_colors.length; i++) {
if (result.colors[i]) {
@@ -52,13 +52,13 @@ function restore_options() {
})
}
function change_mode() {
browser.storage.sync.get("mode", function(result){
chrome.storage.sync.get("mode", function(result){
var input_colors = document.querySelectorAll('input[type="color"]')
switch(result.mode) {
case "light":
document.body.classList.add('dark')
mode = "dark"
browser.storage.sync.set({mode:"dark"})
chrome.storage.sync.set({mode:"dark"})
for (i = 0; i < input_colors.length; i++) {
if (input_colors[i].value == "#cfcfcf") {
input_colors[i].value = "#323234"
@@ -69,7 +69,7 @@ function change_mode() {
case "dark":
document.body.classList.remove('dark')
mode = "light"
browser.storage.sync.set({mode:"light"})
chrome.storage.sync.set({mode:"light"})
for (i = 0; i < input_colors.length; i++) {
if (input_colors[i].value == "#323234") {
input_colors[i].value = "#cfcfcf"


Loading…
Cancel
Save