-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.js
More file actions
20 lines (18 loc) · 691 Bytes
/
popup.js
File metadata and controls
20 lines (18 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* eslint-disable no-undef */
// 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.
const changeColor = document.getElementById('changeColor');
chrome.storage.sync.get('color', (data) => {
changeColor.style.backgroundColor = data.color;
changeColor.setAttribute('value', data.color);
});
changeColor.onclick = function (element) {
const color = element.target.value;
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.executeScript(
tabs[0].id,
{ code: `document.body.style.backgroundColor = "${color}";` },
);
});
};