WTR Lab Smart Quotes

Replaces straight quotes with curly/smart quotes for a better reading experience on wtr-lab.com, without breaking site functionality.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
MasuRiii
日安装量
0
总安装量
3
评分
0 0 0
版本
3.6
创建于
2025-10-18
更新于
2025-10-30
大小
10.3 KB
许可证
MIT
适用于

Before Script After Script

Tired of jarring straight quotes (") and apostrophes (') breaking your immersion while reading novels on wtr-lab.com? This script is a simple, lightweight, and intelligent solution that automatically converts all quotes to their elegant, typographically correct “curly” counterparts.

It works seamlessly in the background to enhance your reading experience, making the text appear cleaner and more professional, just as it would in a published book.

What It Does

  • Automatically Converts Quotes: Replaces straight double quotes ("text") with proper opening and closing “smart quotes” (“text”).
  • Fixes Apostrophes & Single Quotes: Intelligently distinguishes between apostrophes (it’s, Administrator’s), abbreviated years (’88), and single-quoted text (‘word’).
  • Handles Nested Quotes: Correctly formats single quotes within double quotes (“He said, ‘Help me!’”).
  • Converts Dashes: Automatically converts double hyphens (--) into proper em-dashes ().
  • Works on Dynamic Content: The script is built to work with modern websites like wtr-lab.com that load new chapters without a full page refresh. It will automatically process new content as you navigate.
  • Preserves Site Functionality: Does its job without interfering with the website's original features, such as term-definition popovers.
  • Toggle On/Off Instantly: Enable or disable the script at any time via the Tampermonkey menu. The changes apply immediately without needing to refresh the page, making it easy to compare the text or troubleshoot issues.

Why This Script is Smarter

This script goes far beyond a simple search-and-replace. It uses a robust, pattern-based engine to handle complex edge cases that other scripts miss.

  • Fixes Popover/Tooltip Bugs: The core logic was rebuilt to surgically modify only the text content without breaking the website's interactive HTML elements. Term definition popovers will now work perfectly while the script is active.

  • Context-Aware Across HTML Tags: The script maintains context even when words are split by styling tags (e.g., <span>). This prevents errors where an apostrophe at the beginning of a text block is mistaken for an opening quote.

    • Example: <em>Administrator</em>'s is correctly converted to <em>Administrator</em>’s, not <em>Administrator</em>‘s.
  • Advanced Apostrophe Detection: It uses robust, pattern-aware rules to differentiate between contractions/possessives and nested single quotes. This ensures correct formatting even when a quote is followed by punctuation, a common failure point for other scripts.

    • Example: “They’re protesting the term ‘Sinners’,” he said. is formatted perfectly.
    • Example: ...interpret equality as ‘being able to do whatever they want.’ is also handled correctly.
  • Intelligent Contextual Conversion: Instead of a simple character-by-character check, the script now analyzes the entire paragraph's text at once. This allows it to use advanced, pattern-based rules (inspired by professional typography tools) to correctly identify opening/closing quotes and apostrophes, even in complex or ambiguous sentences.

  • Safe and Efficient: It uses a TreeWalker to efficiently find and change only text, leaving all HTML elements and their functionality intact. A MutationObserver ensures it only runs when a new chapter is loaded, keeping your browser fast.

  • Configurable Logging: For developers or users providing feedback, logging can be enabled/disabled via the Tampermonkey menu, keeping your browser console clean.

How to Use

  1. Make sure you have a userscript manager installed, such as Tampermonkey (recommended), Greasemonkey, or Violentmonkey.
  2. Click the green "Install this script" button on this page.
  3. Visit any novel chapter on https://wtr-lab.com. The script will run automatically.
  4. (Optional) To manage the script, click the Tampermonkey icon in your browser, find "WTR Lab Smart Quotes", and select one of the following commands:
    • Toggle Smart Quotes: Instantly enable or disable the script on the current page.
    • Toggle Logging: Enable or disable console logging for debugging.

Feedback and Contributions

If you encounter a word or a sentence where the quotes are not replaced correctly, please open a ticket on the Feedback tab. Suggestions for improvement are always welcome.