chrome-ext-screenshot
v0.1.0
Published
Reusable browser-based screenshot generator for Chrome extension promo images.
Maintainers
Readme
Chrome Extension Screenshot Generator
Reusable HTML + JavaScript toolkit for generating Chrome extension marketing screenshots. Designed to provide:
- Customizable HTML/CSS templates
- One-click downloads for common resolutions (e.g. 1280×800, 640×400)
- Automatic embedding and Data URL copy helpers
- html2canvas loading and convenience helpers
Getting Started
cd chrome-ext-screenshot
npm install
npm run previewOpen the served templates/default.html to experiment. Update text, replace images, and trigger downloads via the buttons.
Structure
lib/generator.js: Core initialization and capture logic (window.ScreenshotGenerator)templates/default.html: Reference template wired up with the librarystyles/default.css: Styling for the templateexamples/: Placeholder assets and notes
Usage
- Copy
lib/generator.jsinto your project or load it via script tag. - Annotate your markup:
- Wrap the screenshot content in an element with
data-screenshot. - Mark the element you want rendered as
data-screenshot-target. - Add buttons with
data-screenshot-download="WIDTHxHEIGHT"ordata-screenshot-width/height. - Optional
data-screenshot-outputnodes receive the generated Data URL or preview.
- Wrap the screenshot content in an element with
- Initialize with
ScreenshotGenerator.init().
<div class="promo" data-screenshot>
<div data-screenshot-target> ... </div>
<button data-screenshot-download="1280x800">Download</button>
</div>
<script src="./lib/generator.js"></script>
<script>
ScreenshotGenerator.init();
</script>Configuration
data-screenshot-width,data-screenshot-height: default capture sizedata-screenshot-filename: base filename without extensiondata-screenshot-background: override background color (transparentby default resolves automatically)data-screenshot-auto="load": auto-generate on load (also supportstrue/embed)data-screenshot-transparent="true": preserve transparencydata-screenshot-html2canvas: custom html2canvas URL
API
ScreenshotGenerator.init({ selector, scope, html2canvasUrl, backgroundColor, transparent });
ScreenshotGenerator.captureElement(element, options);
ScreenshotGenerator.loadHtml2Canvas(url);captureElement returns a promise resolving to a Data URL. Pass { width, height, format, quality, backgroundColor, transparent } as needed.
License
MIT
