| OLD | NEW |
| 1 // Copyright (c) 2011 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 settings in the synchronized repository. | 5 // Store settings in the synchronized repository. |
| 6 var storage = chrome.experimental.storage.sync; | 6 var storage = chrome.storage.sync; |
| 7 var message = document.querySelector('#message'); | 7 var message = document.querySelector('#message'); |
| 8 | 8 |
| 9 // Check if there is CSS specified. | 9 // Check if there is CSS specified. |
| 10 storage.get('css', function(items) { | 10 storage.get('css', function(items) { |
| 11 console.log(items); | 11 console.log(items); |
| 12 // If there is CSS specified, inject it into the page. | 12 // If there is CSS specified, inject it into the page. |
| 13 if (items.css) { | 13 if (items.css) { |
| 14 chrome.tabs.insertCSS(null, {code: items.css}, function() { | 14 chrome.tabs.insertCSS(null, {code: items.css}, function() { |
| 15 if (chrome.extension.lastError) { | 15 if (chrome.extension.lastError) { |
| 16 message.innerText = 'Not allowed to inject CSS into special page.'; | 16 message.innerText = 'Not allowed to inject CSS into special page.'; |
| 17 } else { | 17 } else { |
| 18 message.innerText = 'Injected style!'; | 18 message.innerText = 'Injected style!'; |
| 19 } | 19 } |
| 20 }); | 20 }); |
| 21 } else { | 21 } else { |
| 22 var optionsUrl = chrome.extension.getURL('options.html'); | 22 var optionsUrl = chrome.extension.getURL('options.html'); |
| 23 message.innerHTML = 'Set a style in the <a target="_blank" href="' + | 23 message.innerHTML = 'Set a style in the <a target="_blank" href="' + |
| 24 optionsUrl + '">options page</a> first.'; | 24 optionsUrl + '">options page</a> first.'; |
| 25 } | 25 } |
| 26 }); | 26 }); |
| 27 | 27 |
| OLD | NEW |