Last active
August 22, 2024 08:00
-
-
Save orthlus/3b1ffe27656abfa09629aa672b112c5f to your computer and use it in GitHub Desktop.
habr print button (clean for pdf)
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
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