matts0613

Untitled

May 9th, 2025
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // this script loads the modules needed and then takes a screenshot of the entire site. I made this to capture screenshots purely in the Chrome Developer Tools console, with nothing else needed.
  2. (function () {
  3.     const src = 'https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js';
  4.     const script = document.createElement('script');
  5.     script.type = 'text/javascript';
  6.     script.src = src;
  7.     script.onload = () => {
  8.       html2canvas(document.body, {
  9.         onrendered: (canvas) => {
  10.           const imgageData = canvas.toDataURL('image/png');
  11.           const el = document.createElement('a');
  12.           el.setAttribute('href', imgageData.replace(/^data:image\/png/, 'data:application/octet-stream'));
  13.           el.setAttribute('download', 'screen.png');
  14.           el.style.display = 'none';
  15.           document.body.appendChild(el);
  16.           el.click();
  17.           document.body.removeChild(el);
  18.         }
  19.       });
  20.     };
  21.     document.body.appendChild(script);
  22.   })()
Advertisement
Add Comment
Please, Sign In to add comment