Page Text Downloader/Copier

Floating button to download page text, selected text, or clipboard. Click: download, Hold: copy, Shift+Click: clipboard.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Advertisement:

Autor
piknockyou
Dnevne instalacije
0
Ukupnih instalacija
42
Ocjene
0 0 0
Verzija
8.3
Stvoreno
15.05.2025.
Ažurirano
04.05.2026.
Size
41,8 KB
Licenza
AGPL-3.0
Primjenjuje se
Sve stranice

☕ If you find this tool helpful & would like to support its maintenance, please consider leaving a tip on:

https://ko-fi.com/piknockyou

Thank you! :-)


🖼 For a quick impression of this script, refer to the screenshots at the bottom.


Page Text Downloader

Instantly download any webpage's visible text content as a file. One click for full page, select text for partial export, or download directly from clipboard. Minimal, unobtrusive floating button.


Why You Need This

Saving webpage content is surprisingly tedious:

  • Copy-paste loses context: No source URL, no timestamp, no metadata
  • Browser "Save Page" is bloated: Includes HTML, scripts, styles—not just the text you want
  • Reader modes strip too much: Often loses code blocks, tables, or formatting
  • Manual file creation: Copy → open editor → paste → save as → choose location → name file

This script reduces all of that to a single click.


Key Features

Four Actions, One Button

Action Result
Click Download entire page as .md (NOT MarkDown Formatted!)
Select + Click Download only selected text (prompts for extension)
Shift + Click Download clipboard contents (prompts for extension)
Hold (300ms) Copy page text to clipboard
Double-click Hide button for 5 seconds

Smart File Naming

  • Filename derived from page title
  • Domain automatically appended (e.g., Article_Title_example-com.md)
  • Sanitized for filesystem compatibility

Metadata Header

Downloaded files include an HTML comment header:

<!--
  Source: https://example.com/article/123
  Title: Article Title
  Domain: example.com
  Downloaded: 2025-01-15T10:30:00.000Z
-->

Header included for full page downloads only—selection and clipboard exports remain clean.

Extension Prompt

When downloading selections or clipboard content:

  • Dark mode modal appears
  • Last-used extension remembered across all sites
  • Supports any extension: md, txt, py, json, ps1, etc.
  • Enter to confirm, Escape to cancel

Installation

Requirements

Steps

  1. Install a userscript manager
  2. Install this script
  3. A small document icon appears in the bottom-right corner of every page

Usage Examples

Save an article for offline reading

  1. Navigate to any article
  2. Click the button
  3. .md file downloads instantly with full metadata

Extract a code snippet

  1. Select the code block on the page
  2. Click the button
  3. Choose extension (e.g., py, js, sh)
  4. Clean code file downloads—no surrounding text

Save something you copied earlier

  1. Copy text from anywhere (another app, PDF, etc.)
  2. On any webpage, Shift+Click the button
  3. Choose extension
  4. Clipboard contents saved to file

Quick copy without leaving the page

  1. Hold the button for 300ms
  2. Page text copied to clipboard
  3. Paste wherever needed

Technical Details

  • Shadow DOM Isolation: Button and UI completely isolated from page styles and scripts
  • Works everywhere: Matches *://*/* and file:///*
  • Touch support: Full touch event handling for mobile browsers
  • SPA compatible: Works on single-page applications
  • Minimal footprint: Single 24px button, 15% opacity until hovered
  • No external dependencies: Pure JavaScript, no libraries

Permissions Explained

Permission Purpose
GM_download Trigger file downloads with custom filenames
GM_setClipboard Copy text to clipboard on hold action
GM_getValue / GM_setValue Remember last-used file extension

Configuration

Edit the CONFIG object at the top of the script:

const CONFIG = {
    file: {
        defaultExtension: 'md',      // Change default download format
        includeHeader: true,         // Toggle metadata header
    },
    button: {
        size: 24,                    // Button size in pixels
        position: {
            vertical: 'bottom',      // 'top' or 'bottom'
            horizontal: 'right',     // 'left' or 'right'
            offsetX: 1,
            offsetY: 1
        },
        opacity: {
            default: 0.15,           // Idle opacity
            hover: 1                 // Hover opacity
        }
    },
    timing: {
        copyHoldThreshold: 300,      // Hold duration for copy (ms)
        hideTemporarilyDuration: 5000 // Double-click hide duration (ms)
    }
};

FAQ

Q: The button is in my way. A: Double-click to hide it for 5 seconds. Or edit CONFIG.button.position to move it to a different corner.

Q: Can I change the default file format? A: Yes. Change CONFIG.file.defaultExtension from 'md' to 'txt' or any other extension.

Q: Why does selection/clipboard prompt for extension but full page doesn't? A: Full page downloads use the configured default (.md). Selections and clipboard are assumed to be varied content (code, notes, etc.) where you'd want to specify the format.

Q: Does this work on local HTML files? A: Yes. The script matches file:///* URLs.

Q: The download shows "Downloading..." but nothing happens. A: Some userscript managers require explicit download permissions. Try the fallback: if GM_download fails, the script automatically uses a blob URL approach.

Q: Can I disable the metadata header? A: Yes. Set CONFIG.file.includeHeader to false.