-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (39 loc) · 1.46 KB
/
script.js
File metadata and controls
44 lines (39 loc) · 1.46 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
document.addEventListener('DOMContentLoaded', function () {
const checkElement = setInterval(() => {
const commandDialog = document.querySelector(".quick-input-widget");
if (commandDialog) {
// Check if the command palette element is visible for the first time.
if (commandDialog.style.display !== "none") {
applyBlur();
}
observeCommandDialog(commandDialog);
clearInterval(checkElement);
}
}, 500); // Check every 0.5s
function observeCommandDialog(commandDialog) {
const observer = new MutationObserver(() => {
if (commandDialog.style.display !== "none") {
applyBlur();
} else {
removeBlur();
}
});
observer.observe(commandDialog, { attributes: true });
}
function applyBlur() {
const targetDiv = document.querySelector(".monaco-workbench .part.editor>.content");
let blurElement = document.getElementById("bg-blur");
if (!blurElement) {
blurElement = document.createElement("div");
blurElement.setAttribute('id', 'bg-blur');
blurElement.addEventListener('click', removeBlur);
targetDiv.appendChild(blurElement);
}
}
function removeBlur() {
const blurElement = document.getElementById("bg-blur");
if (blurElement) {
blurElement.remove();
}
}
});