-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
52 lines (49 loc) · 1.8 KB
/
script.js
File metadata and controls
52 lines (49 loc) · 1.8 KB
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
/* eslint-env browser */
(function () {
// change style
const style = Object.freeze({
// button background color
backgroundColor: "#33373e",
backgroundColorHover: "#23252A",
// button text color
color: "#c0c0c0",
// button size
size: "20px",
// border radius
radius: "999px",
fontSize: 8,
fontWeight: "700",
gap: "8px"
});
window.addEventListener("DOMContentLoaded", () => {
let timer = setInterval(() => {
const controls = document.querySelector(".titlebar-container .titlebar-right .window-controls-container")
const leftTitlebar = document.querySelector(".titlebar-container .titlebar-left")
// not loaded
if (!controls || !leftTitlebar) {
return
}
// put close button in first position
controls.parentNode.removeChild(controls)
const closeControl = controls.lastChild
controls.removeChild(closeControl)
controls.prepend(closeControl)
controls.style.width = "auto"
controls.style.gap = controls.style.marginLeft = style.gap
controls.childNodes.forEach((child) => {
child.style.borderRadius = style.radius
child.style.backgroundColor = child.style.backgroundColor = style.backgroundColor
child.style.width = child.style.height = style.size
child.style.color = style.color
child.style.margin = "auto"
child.style.cursor = "pointer"
child.style.fontWeight = style.fontWeight
child.style.fontSize = `${style.fontSize}px`
child.addEventListener("mouseleave", () => child.style.backgroundColor = style.backgroundColor)
child.addEventListener("mouseenter", () => child.style.backgroundColor = style.backgroundColorHover)
})
leftTitlebar.appendChild(controls)
clearInterval(timer)
}, 100)
})
})();