-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-regex.js
58 lines (42 loc) · 1.91 KB
/
custom-regex.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var colour = localStorage.getItem("colour");
if (colour) {
var styleElement = document.getElementsByTagName("style")[0];
styleElement.innerHTML += `
nav, button, .card {
background-color: ${colour};
}
button:hover, #back:hover {
background-color: ${colour.replace("0.25", "0.5")};
}
`;
document.getElementById("back").addEventListener("mouseover", () => {
document.getElementById("back").style.backgroundColor = colour.replace("0.25", "0.5");
});
document.getElementById("back").addEventListener("mouseleave", () => {
document.getElementById("back").style.backgroundColor = "";
});
document.getElementById("custom-regex").style.backgroundColor = colour;
document.getElementById("custom-regex").addEventListener("mouseover", () => {
document.getElementById("custom-regex").style.backgroundColor = colour.replace("0.25", "0.5");
});
document.getElementById("custom-regex").addEventListener("mouseleave", () => {
document.getElementById("custom-regex").style.backgroundColor = colour;
});
document.getElementById("filename").style.backgroundColor = colour;
document.getElementById("filename").addEventListener("mouseover", () => {
document.getElementById("filename").style.backgroundColor = colour.replace("0.25", "0.5");
});
document.getElementById("filename").addEventListener("mouseleave", () => {
document.getElementById("filename").style.backgroundColor = colour;
});
}
document.getElementById("filename").value = localStorage.getItem("filename");
document.getElementById("custom-regex").value = localStorage.getItem("custom-regex");
setInterval(() => {
let customRegex = localStorage.getItem("custom-regex");
while (customRegex.includes("/")) {
customRegex = customRegex.replace("/", "");
}
customRegex = RegExp(customRegex);
document.getElementById("result").innerText = localStorage.getItem("filename").replace(customRegex, '');
});