1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Store CSS data in the "local" storage area.
6//
7// See note in options.js for rationale on why not to use "sync".
8var storage = chrome.storage.local;
9
10var message = document.querySelector('#message');
11
12// Check if there is CSS specified.
13storage.get('css', function(items) {
14  console.log(items);
15  // If there is CSS specified, inject it into the page.
16  if (items.css) {
17    chrome.tabs.insertCSS({code: items.css}, function() {
18      if (chrome.runtime.lastError) {
19        message.innerText = 'Not allowed to inject CSS into special page.';
20      } else {
21        message.innerText = 'Injected style!';
22      }
23    });
24  } else {
25    var optionsUrl = chrome.extension.getURL('options.html');
26    message.innerHTML = 'Set a style in the <a target="_blank" href="' +
27        optionsUrl + '">options page</a> first.';
28  }
29});
30
31