Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

pratikkabade/screenshot-bookmarklet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ss-bookmarklet

Overview

A simple bookmarklet that captures a screenshot of the current page and downloads it as a PNG. There are two variants:

  • One that saves a single 1920×1080 image
  • One that also saves a 200×150 thumbnail alongside the main image

No data is sent anywhere. Images are generated in-memory and downloaded directly by your browser.

Files

  • ss.js: Readable source for a single 1920×1080 screenshot
  • ss-with-thumb.js: Readable source that also generates a 200×150 thumbnail
  • min-ss.js: Minified bookmarklet for production use (single image)
  • min-ss-with-thumb.js: Minified bookmarklet for production use (image + thumbnail)
  • min.py: Python script that minifies the readable sources into the min-* files (uses jsmin)

How it works

  • On click, the bookmarklet first looks for html2canvas. If present, it captures the rendered DOM: html2canvas(document.documentElement).
  • If html2canvas is not present or fails, it falls back to native screen capture via navigator.mediaDevices.getDisplayMedia, requesting the current tab/window. The browser will prompt you to choose what to share.
  • The captured image is resized to a fixed size of 1920×1080 (TARGET_WIDTH/TARGET_HEIGHT) before download.
  • Files are named using the site/page context and a counter: <page>-screenshot-<n>.png.
  • The thumbnail variant also downloads <page>-screenshot-<n>-thumb.png (200×150).
  • A simple counter is tracked in localStorage under ss_bookmarklet_screenshot_counter (with a safe in-memory fallback if localStorage is unavailable).

Create the bookmarklet

You will create a browser bookmark whose URL is the JavaScript code from one of the min-* files.

  1. Open min-ss.js (single image) or min-ss-with-thumb.js (image + thumbnail) in your editor or GitHub and copy its entire contents.
  2. Create a new bookmark in your browser:
  • Chrome/Edge/Brave
    • Show the bookmarks bar if hidden (Ctrl+Shift+B)
    • Right-click the bar → Add page…
    • Name: e.g., "Screenshot" or "Screenshot + Thumb"
    • URL: paste the code you copied (it must start with javascript:)
    • Save
  • Firefox
    • Right-click the bookmarks toolbar → New Bookmark…
    • Name: as you like
    • Location (URL): paste the code (must start with javascript:)
    • Add

To use: navigate to any page and click the bookmarklet. Your browser may prompt for permission to capture a tab/window; choose the current tab for best results.

Output naming

  • Base filename: <page>-screenshot-<n>.png
    • <page> is derived from the hostname (or page title as a fallback), lowercased and slugified
    • <n> increments per screenshot using localStorage
  • Thumbnail variant adds: <page>-screenshot-<n>-thumb.png

Development and minification workflow

Minified files are already committed (min-ss.js, min-ss-with-thumb.js). If you modify the readable sources, regenerate the minified files as follows:

Requirements:

  • Python 3.x
  • jsmin package

Install dependency:

  • Windows PowerShell: python -m pip install jsmin (or py -m pip install jsmin)
  • macOS/Linux: python3 -m pip install jsmin

Run the minifier from the repo root:

  • Windows PowerShell: python min.py (or py min.py)
  • macOS/Linux: python3 min.py

This will:

  • Read ss.js → write min-ss.js
  • Read ss-with-thumb.js → write min-ss-with-thumb.js

Customization

Edit ss.js or ss-with-thumb.js as needed, then re-run min.py.

  • Screenshot size: change TARGET_WIDTH and TARGET_HEIGHT (defaults: 1920×1080)
  • Thumbnail size (thumb variant): change THUMB_WIDTH and THUMB_HEIGHT (defaults: 200×150)
  • Naming: update getPageName() or the filename template in the save functions

Troubleshooting

  • The browser asks what to share
    • Choose the current tab (or window) to capture what you see. This is required by browser security when using screen capture.
  • Nothing happens when clicked
    • Ensure the bookmark URL begins with javascript: and the code is unmodified.
    • Some pages block bookmarklets in iframes; try opening the page in a top-level tab.
  • Only one of the files downloads, or the browser blocks downloads
    • Allow multiple automatic downloads for the site in the browser’s permissions if prompted.
  • html2canvas path
    • If the page does not already include html2canvas, the bookmarklet will automatically fall back to screen capture.

Privacy and security

  • The code does not make network requests or upload content. Images are generated as in-memory blobs and downloaded locally.
  • When using screen capture (getDisplayMedia), the browser’s built-in permission prompt appears. Nothing is captured until you explicitly choose a tab/window to share.

Notes

  • Works best in modern Chromium-based browsers and recent Firefox versions.
  • If you keep this repository on GitHub, you can point collaborators to the min-* files to create their bookmarklets quickly.

About

(❌) A simple bookmarklet that captures a screenshot of the current page and downloads it as a PNG.

Topics

Resources

Stars

Watchers

Forks

Contributors