Skip to content

Instantly share code, notes, and snippets.

@NicHub
Last active August 15, 2025 16:00
Show Gist options
  • Select an option

  • Save NicHub/f9394886b20bfba5c6a15f5d95e90f1a to your computer and use it in GitHub Desktop.

Select an option

Save NicHub/f9394886b20bfba5c6a15f5d95e90f1a to your computer and use it in GitHub Desktop.
JS CONSOLE SNIPPETS

Enable select and copy on every element of a web page

document.querySelectorAll('*').forEach(el => { el.style.userSelect = 'auto'; el.style.webkitUserSelect = 'auto'; el.style.mozUserSelect = 'auto'; el.style.msUserSelect = 'auto'; el.oncontextmenu = null; el.onselectstart = null; el.ondragstart = null; el.onmousedown = null; }); document.onselectstart = null; document.oncontextmenu = null; document.ondragstart = null; document.onmousedown = null; document.body.style.userSelect = 'auto';

Print single page PDF

heightMultiplier = 10;
document.head
    .appendChild(document.createElement("style"))
    .sheet.insertRule(`@page { size: 21cm ${heightMultiplier * 29.7}cm; }`, 0);
window.print();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment