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

作者
iamnobody
日安装量
0
总安装量
0
评分
0 0 0
版本
2.0.0
创建于
2025-09-23
更新于
2025-09-23
大小
13.9 KB
许可证
MIT
适用于
所有网站

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.