Browse Source

check to see if synced settings exist

dev
Kyle Mitchell 2 years ago
parent
commit
47fbd9af05
  1. 32
      js/index.js
  2. 18
      js/options.js
  3. 2
      manifest.json

32
js/index.js

@ -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) {

18
js/options.js

@ -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]
}
}
}
})

2
manifest.json

@ -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