How can I freeze all JS DOM changes completely using JS from a chrome extension?
Example: a user hovers over a button, which onMouseEnter displays a modal and hides it onMouseLeave.
If I bind a callback to a certain keyboard-shortcut, how can I freeze the DOM in that point in time so that the modal stays visible and nothing can change in the DOM anymore (until the shortcut is pressed again) ?
I know there might not be a direct API to freeze the DOM, but I'm looking for any ideas that can help me do this.
One Idea I tried was:
However that didn't work, if I hovered my mouse over the button and the modal showed up, then I invoked that algorithm with the keybind, the cloning would happen successfully and script tags would be removed, however when I remove the mouse from the button the modal would just close. As if the button was still bound to onMouseLeave.
Edit: I'm trying to do this from an external script, specifically a chrome extension.
if you have a function "myFunc" and want to malfunction it or disable it. you can clear the contents in window object.
<button onclick="freeze()">Freeze alert</button>
<button onclick="testAlert()">Test alert</button>
<script>
function freeze() {
window.testAlert = function testAlert() { };
}
function testAlert() {
alert('The alert is active');
}
</script>
The alert button will not work after clicking the freeze button.