Created
November 6, 2024 02:03
-
-
Save vuboi/5133610959410f3e6056cb50f3936f65 to your computer and use it in GitHub Desktop.
vscode_custom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment