Last active
March 24, 2025 14:42
-
-
Save 825i/965c939383e6bc89cd8a25c93bb204d6 to your computer and use it in GitHub Desktop.
Hide Migaku Extension GrabbyTabby on asbplayer's website
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
// ==UserScript== | |
// @name Hide Migaku GrabbyTabby | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Hides the Migaku GrabbyTabby on asbplayer page | |
// @author You | |
// @match https://killergerbah.github.io/asbplayer/* | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// CSS to hide the ToolbarGrabbyTabby | |
const hideToolbarCSS = ` | |
.ToolbarGrabbyTabby__wrapper { | |
display: none !important; | |
} | |
`; | |
// Function to inject the style into the shadow DOM | |
function injectStyleToShadowDOM() { | |
const migakuShadowDom = document.getElementById('MigakuShadowDom'); | |
if (migakuShadowDom && migakuShadowDom.shadowRoot) { | |
const style = document.createElement('style'); | |
style.id = 'migaku-toolbar-hider'; | |
style.textContent = hideToolbarCSS; | |
migakuShadowDom.shadowRoot.appendChild(style); | |
return true; | |
} | |
return false; | |
} | |
// Use MutationObserver to detect when the shadow DOM is added to the page | |
const observer = new MutationObserver((mutations) => { | |
for (const mutation of mutations) { | |
if (mutation.addedNodes) { | |
for (const node of mutation.addedNodes) { | |
if (node.id === 'MigakuShadowDom') { | |
// Wait a brief moment for the shadow DOM to be fully initialized | |
setTimeout(() => { | |
if (injectStyleToShadowDOM()) { | |
observer.disconnect(); // Stop observing once we've injected the style | |
} | |
}, 100); | |
} | |
} | |
} | |
} | |
}); | |
// Start observing the document body for changes | |
observer.observe(document.body, { childList: true, subtree: true }); | |
// Try to inject immediately in case the element already exists | |
if (injectStyleToShadowDOM()) { | |
observer.disconnect(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add additional URLs to line 7:
That you want the script to work on.