/
index.js
33 lines (26 loc) · 1.04 KB
/
index.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
function debugCSS(options) {
if (typeof options.selector === "undefined" && typeof options.not === "undefined") {
var selector = document.querySelectorAll("*");
}
else if (typeof options.selector === "undefined") {
var selector = document.querySelectorAll(`*:not(${options.not}) > *`);
}
else if (typeof options.selector != "undefined" && typeof options.not === "undefined") {
var selector = document.querySelectorAll(`${options.selector}, ${options.selector} *`);
}
else {
var selector = document.querySelectorAll(`${options.selector}:not(${options.not}), ${options.selector} > :not(${options.not}) > *`);
}
function randomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = "#";
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
selector.forEach(function (el) {
el.style.outline = `1px solid ${randomColor()}`;
});
}
module.exports.debugCSS = debugCSS;