Skip to content

Instantly share code, notes, and snippets.

@orthlus
Last active August 22, 2024 08:00
Show Gist options
  • Save orthlus/3b1ffe27656abfa09629aa672b112c5f to your computer and use it in GitHub Desktop.
Save orthlus/3b1ffe27656abfa09629aa672b112c5f to your computer and use it in GitHub Desktop.
habr print button (clean for pdf)
function appendPrintButton() {
const button = document.createElement("button");
button.innerText = "GET PDF";
button.id = "pdf-button";
button.style.margin = '0 20px'
document.querySelector('.tm-main-menu__section').appendChild(button);
function deleteEl(el) {
if (el !== null) {
el.remove()
}
}
document.getElementById("pdf-button")
.addEventListener('click', () => {
deleteEl(document.querySelector('.tm-page__header'))
deleteEl(document.querySelector('.tm-company-profile-card'))
deleteEl(document.querySelector('.tm-article-author'))
deleteEl(document.querySelector('.tm-article-presenter__footer'))
deleteEl(document.querySelector('.tm-footer-menu'))
deleteEl(document.querySelector('.tm-layout-sidebar'))
deleteEl(document.querySelector('.tm-footer'))
deleteEl(document.querySelector('.tm-header'))
deleteEl(document.querySelector('.tm-adfox-banner__container'))
window.print()
});
}
setTimeout(appendPrintButton, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment