-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
34 lines (27 loc) · 809 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const colorEl = document.getElementById("color-changer");
const rotateEl = document.getElementById("rotate");
const rotate3DEl = document.getElementById("rotate3d");
colorEl.addEventListener("input", () => {
injectCSS(`body {
background-color: ${colorEl.value}!important;
}`);
});
rotateEl.addEventListener("input", () => {
injectCSS(`body {
transform: rotate(${rotateEl.value}deg)!important;
}`);
});
rotate3DEl.addEventListener("input", () => {
injectCSS(`body {
transform: rotate3d(1,20,1,${rotate3DEl.value}deg)!important;
}`);
});
function injectCSS(css) {
chrome.tabs.query({ active: true, currentWindow: true }, ([tab]) => {
if (!tab) return;
chrome.scripting.insertCSS({
css,
target: { tabId: tab.id },
});
});
}