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