Silent Article Printer (Readability intercept)

Silently replace page content with the parsed main article when user invokes Print. Keeps selectable text, constrains layout to A4 with 0 visual margins where possible, scales wide media to fit A4. Opens native print dialog for user confirmation. Works on most websites; excludes common search engines. MIT License. Author: iamnobody

目前為 2025-09-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
iamnobody
評價
0 0 0
版本
2.0.0
建立日期
2025-09-23
更新日期
2025-09-23
尺寸
13.9 KB
授權條款
MIT
腳本執行於
所有網站

// ==UserScript==
// @name Article-to-PDF (Article-only Print Cleaner)
// @namespace https://tampermonkey.net/
// @version 1.0
// @description Automatically extracts the main article text (with images/tables) from any website (excluding search engines) and presents only that content when you print (Ctrl+P / Cmd+P). This ensures a clean, margin-free, ad-free, header-free print preview with selectable text. After printing, the original page is restored. MIT License.
// @author iamnobody
// @match *://*/*
// @exclude *://www.google.*/*
// @exclude *://www.bing.com/*
// @exclude *://duckduckgo.com/*
// @exclude *://search.yahoo.com/*
// @grant none
// @license MIT
// ==/UserScript==

/*
===========================
Description & Usage
===========================

What this script does:
- Detects the main article content automatically (using Mozilla Readability + sanitization).
- Removes ads, sidebars, footers, and unnecessary UI.
- Keeps article images, tables, and code blocks intact.
- Scales wide elements to fit A4 portrait paper (instead of wasting pages).
- Intercepts print commands (Ctrl+P / Cmd+P or browser menu Print).
- Shows only the clean article in the print preview dialog.
- Lets you confirm the print/save normally (no auto-download, no floating button).
- Restores the original page automatically after printing or canceling.
- If auto-detection fails, shows a tiny overlay asking you to click the article block.
- Works on Chrome and Firefox. (Other Chromium browsers may also work.)
- Excludes major search engines.

Limitations:
- Browser-added headers/footers (URL, date, page number) cannot be removed by scripts. You must disable them manually in the print dialog (Margins → None; uncheck headers/footers).
- The filename for the PDF depends on the browser’s print dialog; the script cannot force a name.
- Page scaling rules: default is A4 portrait with scaling. Very wide elements are shrunk to fit; they will not switch paper size.

How to use:
1. Install Tampermonkey (Chrome/Firefox/Edge).
2. Create a new userscript and paste the full code (this header + script body).
3. Enable the script.
4. Visit any news, blog, or study article page.
5. Press Ctrl+P (Windows/Linux) or Cmd+P (Mac) — or use File → Print in the browser menu.
6. You will see only the clean article in the print preview.
7. Turn off browser headers/footers in the print settings if you want a truly blank PDF.
8. Save/print as usual.
9. When finished, the original page automatically returns.

Debugging:
- Open DevTools (F12 → Console) to see logs if the script fails to detect the article.
- If detection fails often, enable the fallback by clicking the overlay to select the article manually.
*/