Browse Source

check to see if synced settings exist

dev
Kyle 10 months ago
parent
commit
47fbd9af05
3 changed files with 30 additions and 22 deletions
  1. +18
    -14
      js/index.js
  2. +11
    -7
      js/options.js
  3. +1
    -1
      manifest.json

+ 18
- 14
js/index.js View File

@@ -1,25 +1,29 @@
function restore_options() {
browser.storage.sync.get("links", function(result){
var quads = document.querySelectorAll('a')
for (i = 0; i < quads.length; i++) {
if (result.links[i]) {
var link = result.links[i]
if (link.substring(0, 4) === 'http' ? link = 'options.html' : link = 'http://' + link)
quads[i].href = link
if (result.links) {
var quads = document.querySelectorAll('a')
for (i = 0; i < quads.length; i++) {
if (result.links[i]) {
var link = result.links[i]
if (link.substring(0, 4) === 'http' ? link = 'options.html' : link = 'http://' + link)
quads[i].href = link
}
}
}
})
browser.storage.sync.get("colors", function(result){
var quads = document.querySelectorAll('a')
var style = document.createElement('style');
for (i = 0; i < quads.length; i++) {
if (result.colors[i]) {
style.appendChild(
document.createTextNode('.content a:nth-child(' + (i + 1) + '):hover ~ svg polygon { fill: ' + result.colors[i] + '}')
)
if (result.colors) {
var quads = document.querySelectorAll('a')
var style = document.createElement('style');
for (i = 0; i < quads.length; i++) {
if (result.colors[i]) {
style.appendChild(
document.createTextNode('.content a:nth-child(' + (i + 1) + '):hover ~ svg polygon { fill: ' + result.colors[i] + '}')
)
}
}
document.head.appendChild(style)
}
document.head.appendChild(style)
})
browser.storage.sync.get("mode", function(result){
if (result.mode) {


+ 11
- 7
js/options.js View File

@@ -37,16 +37,20 @@ function restore_options() {
}
})
browser.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]
if (result.links) {
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){
var input_colors = document.querySelectorAll('input[type="color"]')
for (i = 0; i < input_colors.length; i++) {
if (result.colors[i]) {
input_colors[i].value = result.colors[i]
if (result.colors) {
var input_colors = document.querySelectorAll('input[type="color"]')
for (i = 0; i < input_colors.length; i++) {
if (result.colors[i]) {
input_colors[i].value = result.colors[i]
}
}
}
})


+ 1
- 1
manifest.json View File

@@ -1,7 +1,7 @@
{
"name": "Quad - New Tab",
"short_name": "Quad",
"version": "1.1",
"version": "1.1.1",
"manifest_version": 2,
"description": "A minimal New Tab page",
"author": "Kyle Mitchell",


Loading…
Cancel
Save