move default styles

This commit is contained in:
alexadam 2017-05-20 11:47:59 +03:00
parent 9e3ed840fd
commit ad1abc5f61
2 changed files with 14 additions and 11 deletions

View file

@ -32,7 +32,18 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.type === 'get styles') { if (request.type === 'get styles') {
chrome.storage.local.get('styles', function (data) { chrome.storage.local.get('styles', function (data) {
if (!data || !data.styles) { if (!data || !data.styles) {
sendResponse({styles: []}); // TODO move defaultStyles in a different file/location ?
var defaultStyles = [
{
title: 'reddit',
url: 'reddit.com',
style: `.class: {
display: none;
}
`
}
];
sendResponse({styles: defaultStyles});
} else { } else {
sendResponse({styles: data.styles}); sendResponse({styles: data.styles});
} }

View file

@ -8,15 +8,7 @@ if (tmp) {
} }
var allPagesRef = null; var allPagesRef = null;
var allStyles = [{ var allStyles = [];
title: 'reddit',
url: 'reddit.com',
style: `
.class: {
display: none;
}
`
}];
var currentStyle = null; var currentStyle = null;
var currentStyleIndex = -1; var currentStyleIndex = -1;
@ -177,7 +169,7 @@ function showEditor() {
function createStyleList(allStylesTmp) { function createStyleList(allStylesTmp) {
if (allStylesTmp && allStylesTmp.length > 0) { if (allStylesTmp && allStylesTmp.length > 0) {
allStyles = allStyles.slice(0, 0).concat(allStylesTmp); allStyles = allStyles.concat(allStylesTmp);
} }
while (existingStyles.hasChildNodes() && existingStyles.childElementCount > 1) { while (existingStyles.hasChildNodes() && existingStyles.childElementCount > 1) {