WTR Lab Smart Quotes

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

作者
MasuRiii
今日安裝
0
安裝總數
6
評價
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.