Created
April 26, 2024 10:39
-
-
Save enomoto/fea27008e00fadfb2d916cd2c1046d78 to your computer and use it in GitHub Desktop.
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
const hideHeaderAndFooter = (document) => { | |
const noneDisplayQuerySelectors = [ | |
"#shopify-section-announcement-bar", | |
"#shopify-section-announcement", | |
"#shopify-section-header", | |
"#shopify-section-footer", | |
"shop-login-button" | |
] | |
noneDisplayQuerySelectors.forEach((querySelector) => { | |
const element = document.querySelector(querySelector) | |
if (element !== null) { | |
element.style.display = "none" | |
} | |
}) | |
} | |
const trimHeaderSpace = (document) => { | |
const element = document.querySelector(".bodyWrap") | |
if (element !== null) { | |
element.style.paddingTop = "0" | |
} | |
} | |
const target = document | |
const observer = new MutationObserver((mutations) => { | |
mutations.forEach((mutation) => { | |
const document = mutation.target | |
hideHeaderAndFooter(document) | |
trimHeaderSpace(document) | |
}) | |
}) | |
const config = { | |
subtree: true, | |
characterData: true, | |
childList: true | |
} | |
observer.observe(target, config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment