Created
April 23, 2021 06:34
-
-
Save anantoghosh/ce31c471af256c0438c213357ae4929f to your computer and use it in GitHub Desktop.
Clean Confluence page for saving/printing
This file contains 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
/** | |
* Clean Confluence page for saving/printing | |
* Compared to save as pdf feature in confluence, this maintains the exact visual style. | |
* Save this in Sources -> Snippets | |
*/ | |
// Remove top navigation | |
document.querySelector('[data-testid=grid-topNav]')?.remove() | |
// Remove toolbar | |
document.querySelector('[data-test-id=header-animated-box]')?.remove() | |
// Remove left sidebar | |
document.querySelector('[data-testid=grid-left-sidebar]')?.remove() | |
// Remove likes | |
document.querySelector('[data-test-id=likes-and-labels-container]')?.remove() | |
// Remove comments | |
document.querySelector('[data-test-id=comments-section-fabric-new]')?.remove() | |
// Change last updated text to current time | |
document.querySelector('[data-test-id=page-last-modified]').textContent = `Last updated: ${new Intl.DateTimeFormat(undefined,{ | |
dateStyle: 'long', | |
timeStyle: 'long', | |
timeZone: 'UTC', | |
}).format(new Date())}` | |
// Remove view count | |
document.querySelector('[data-webitem-location="system.content.byline"]')?.remove() | |
// Remove anchor icons | |
document.querySelectorAll('.heading-anchor-wrapper').forEach(item => item?.remove()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment