Created
February 15, 2022 21:12
-
-
Save gnimmelf/f9aa963e094f2d9148a57addb0a8d6b0 to your computer and use it in GitHub Desktop.
Ghost 4 - Remove “Publish with Ghost” button on portal
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
/** | |
* Add this to site footer codeinjection | |
*/ | |
// <script> | |
window.onload = () => { | |
let observer; | |
const targetNode = document.getElementById('ghost-portal-root'); | |
observer = new MutationObserver((mutations) => { | |
mutations.forEach(({ addedNodes }) => { | |
Array.from(addedNodes) | |
.map(({ firstChild }) => firstChild) | |
.filter((node) => { | |
const found = | |
node && | |
node.nodeName === 'IFRAME' && | |
node.title == 'portal-popup'; | |
return found; | |
}) | |
.forEach((node) => { | |
node.onload = () => { | |
const { contentDocument } = node; | |
const styleElm = document.createElement('style'); | |
styleElm.type = 'text/css'; | |
contentDocument.head.appendChild(styleElm); | |
styleElm.sheet.insertRule( | |
'.gh-portal-powered { display: none}', | |
0 | |
); | |
observer.takeRecords(); | |
}; | |
}); | |
}); | |
}); | |
observer.observe(targetNode, { childList: true, subtree: false }); | |
}; | |
// </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment