mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-04-12 06:09:05 +07:00
22 lines
681 B
JavaScript
22 lines
681 B
JavaScript
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
'use strict';
|
|
|
|
let changeColor = document.getElementById('changeColor');
|
|
|
|
chrome.storage.sync.get('color', function(data) {
|
|
changeColor.style.backgroundColor = data.color;
|
|
changeColor.setAttribute('value', data.color);
|
|
});
|
|
|
|
changeColor.onclick = function(element) {
|
|
let color = element.target.value;
|
|
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
|
chrome.tabs.executeScript(
|
|
tabs[0].id,
|
|
{code: 'document.body.style.backgroundColor = "' + color + '";'});
|
|
});
|
|
};
|