Teknuk DataMapper is a Chrome Extension (Manifest V3) that lets you visually select elements on any webpage, map them to named fields, and extract structured data. It’s built as a modular extension with a Svelte + TailwindCSS drawer-style popup, a content script for selection and extraction, and utility modules for exporting data and computing selectors.
You can:
- 🔍 Visually select elements on any page
- 🏷️ Assign field names and choose CSS or XPath selectors
- 📦 Save field mappings as templates
- 📤 Extract structured data (supports multiple matches per selector → arrays)
- 💾 Download results as JSON, YAML, TOON, CSV, or XML
- 📁 Import/export templates as JSON (merge or replace)
- Toggle Selection Mode from the popup.
- Hover → element gets a solid border + semi-transparent overlay.
- Click → a tooltip appears near the element:
- Enter field name
- Choose selector type:
cssorxpath
- Save → mapping is persisted in
chrome.storage.localunder the schema:
{
"templateName": {
"fieldName": {
"type": "css" | "xpath",
"selector": "..."
}
}
}-
Organize mappings into templates, e.g.
product-page,blog-listing. -
Switch current template from the drawer.
-
New templates auto-saved to
chrome.storage.local. -
Import & export all templates as JSON.
- Merge mode (default) – merges with existing templates.
- Replace mode – overwrites all existing templates.
-
Auto-overwrite template names with a toast notification.
-
Click Extract in the popup.
-
For each field:
- If
css, usesquerySelectorAll. - If
xpath, usesdocument.evaluate.
- If
-
All matches are captured →
fieldNamealways maps to an array of values. -
Extraction result payload:
{
"templateName": "currentTemplate",
"url": "https://example.com",
"timestamp": 1700000000000,
"data": {
"title": ["Product A", "Product B"],
"price": ["10", "20"]
}
}From the drawer you can download extraction results as:
- JSON
- YAML
- TOON
- CSV
- XML
Filenames follow:
{templateName}-{YYYYMMDD-HHMMSS}.{ext}
e.g.:
product-page-20251126-142233.json
-
manifest.jsonManifest V3 configuration (permissions, background worker, popup, content scripts). -
service-worker.jsBackground service worker:- Forwards messages from popup → content script.
- Relays extraction results to the popup.
-
content-script.jsInjected into all pages:- Handles selection mode UX (highlighting, tooltip).
- Stores mappings into
chrome.storage.local. - Performs data extraction given a template.
-
popup.html/popup.jsBuilt Svelte app:- Drawer-style UI for templates, fields, selection toggle, extraction, and exports.
Source under src/popup/:
App.svelte– main drawer UI.main.js– bootstraps Svelte.index.html– dev entry for Vite.src/styles.css– Tailwind entry.
Located in src/utils/:
highlight.js– selection mode overlays and tooltip.xpath.js– XPath generation from DOM elements.exporters.js– JSON / YAML / TOON / CSV / XML export + filename helper.storage.js– load/save/import/export templates.
Two levels of tests are included:
-
exporters.test.js- Validates filename format.
- Ensures CSV generation is correct (headers + rows).
-
xpath.test.js- Basic XPath generation checks (e.g. ID-based XPath).
Run via:
npm test(Using vitest.)
-
datamapper.e2e.test.js(skeleton) Uses Puppeteer (or similar) to:- Load the extension.
- Open a target page.
- (Extend to) simulate mapping fields and extracting data.
Run via:
npm run test:e2eYou’ll need to adjust the E2E script to match your environment and CI.
npm installnpm run dev- Open the dev server URL (from Vite) to iterate on the drawer UI.
- Tailwind is configured via
tailwind.config.cjsandpostcss.config.cjs.
npm run buildThis:
-
Builds the Svelte popup via Vite.
-
Copies the compiled popup bundle to:
popup.htmlpopup.js
Make sure your root folder contains at least:
manifest.jsonservice-worker.jscontent-script.jspopup.htmlpopup.js
- Open
chrome://extensions. - Enable Developer mode.
- Click Load unpacked.
- Select the project root folder.
You should now see Teknuk DataMapper in the toolbar.
-
Open a webpage you want to scrape.
-
Click the Teknuk DataMapper icon to open the popup (drawer).
-
In the drawer:
- Choose or create a Template.
- Set default selector type (CSS/XPath).
-
Click Start selecting.
-
On the page:
- Hover over elements to see the highlight.
- Click an element → tooltip appears.
- Enter field name, choose CSS/XPath, click Save.
-
Back in the drawer:
- See mapped fields with selector details.
- Click Extract to collect data from the current page.
-
Download results as JSON, YAML, TOON, CSV, or XML.
-
Creating templates Enter a name in the “New template” input and click
+. -
Overwriting templates Creating a template with an existing name overwrites the mapping.
- A small toast appears to inform you.
-
Export templates Click Export templates to download a JSON file of all templates.
-
Import templates (merge) Choose a JSON file in the Import (merge) input:
- New templates are added.
- Existing templates with the same name are merged (fields overwrite by name).
-
Import templates (replace) Choose a JSON file in the Import (replace) input:
- All existing templates are replaced by the imported ones.
- Extension platform: Chrome Extension, Manifest V3
- UI: Svelte + TailwindCSS
- Background: MV3 service worker
- Content script: vanilla JS + DOM APIs
- Storage:
chrome.storage.local - Build: Vite + Svelte plugin
- Testing: Vitest (unit), Puppeteer/Node (E2E skeleton)