Skip to content

Instantly share code, notes, and snippets.

@gnimmelf
Created February 15, 2022 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnimmelf/f9aa963e094f2d9148a57addb0a8d6b0 to your computer and use it in GitHub Desktop.
Save gnimmelf/f9aa963e094f2d9148a57addb0a8d6b0 to your computer and use it in GitHub Desktop.
Ghost 4 - Remove “Publish with Ghost” button on portal
/**
* 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