-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcss-debugger.js
34 lines (30 loc) · 1.18 KB
/
css-debugger.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 addStyles = () => {
var css = `
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
* * * * * * * { background-color: rgba(255,0,0,.2); }
* * * * * * * * { background-color: rgba(0,255,0,.2); }
* * * * * * * * * { background-color: rgba(0,0,255,.2); }`,
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.classList.add('css-debugger-from-chrome-extention-43133');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
}
const removeStyles = () => {
const style = document.querySelector('.css-debugger-from-chrome-extention-43133');
style.remove();
}
const toggleStyles = () => {
const style = document.querySelector('.css-debugger-from-chrome-extention-43133');
if (style) {
removeStyles();
} else {
addStyles();
}
}