Yuan Currency Converter

Convert Chinese Yuan (¥) prices to EUR/USD automatically with real-time rates

作者
enzomtpYT
日安装量
0
总安装量
0
评分
0 0 0
版本
1.2
创建于
2025-07-19
更新于
2025-07-19
大小
10.3 KB
许可证
暂无
适用于

YuanConv - Yuan Currency Converter

A Violentmonkey/Tampermonkey userscript that automatically converts Chinese Yuan (¥) prices to EUR or USD on buff.163.com using real-time exchange rates.

Features

  • Multi-Currency Support: Convert to both EUR (€) and USD ($)
  • Real-time Exchange Rates: Fetches current CNY rates from a reliable API
  • HTML Structure Support: Handles complex price formats like ¥ 11<small>.7</small>
  • Dynamic Content: Works with both static and dynamically loaded content
  • Persistent Settings: Remembers your currency preference using GM storage
  • Interactive Settings UI: Clean settings box with currency selection
  • Keyboard Shortcuts: Quick access via Ctrl+Shift+Y
  • Fallback Protection: Uses backup rates if API fails
  • Auto-updates: Monitors page changes and converts new prices automaticallyn to Euro Converter

A Violentmonkey/Tampermonkey userscript that automatically converts Chinese Yuan (¥) prices to Euros (€) on buff.163.com using real-time exchange rates.

Features

  • Real-time Exchange Rates: Fetches current CNY to EUR rates from a reliable API
  • HTML Structure Support: Handles complex price formats like ¥ 11<small>.7</small>
  • Dynamic Content: Works with both static and dynamically loaded content
  • Fallback Protection: Uses a backup rate if API fails
  • Auto-updates: Monitors page changes and converts new prices automatically

Installation

  1. Install a userscript manager:

  2. Click on the raw script link or copy the script content

  3. Your userscript manager should automatically detect and prompt you to install the script

  4. Enable the script and visit buff.163.com

How It Works

The script automatically detects and converts various yuan price formats to your selected currency:

Simple Format

  • ¥ 3588427.37€ (EUR) or $499.49 (USD)
  • ¥ 1,234147.84€ (EUR) or $171.84 (USD)

Complex HTML Format (buff.163.com specific)

  • <strong>¥ 11<small>.7</small></strong>1.40€ (EUR) or $1.63 (USD)
  • <strong>¥ 2,588<small>.5</small></strong>309.84€ (EUR) or $360.12 (USD)

Currency Selection

The script includes an interactive settings panel where you can:

  • Switch between EUR (€) and USD ($)
  • View current exchange rates
  • Save preferences permanently

Controls

  • Settings Panel: Appears automatically on page load
  • Keyboard Shortcut: Ctrl+Shift+Y to show/hide settings
  • Console Command: Type YuanConvShowSettings() in browser console
  • Auto-hide: Settings panel disappears after 10 seconds

API Integration

The script fetches real-time exchange rates from:

https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/cny.json

Response format:

{
  "date": "2025-07-19",
  "cny": {
    "usd": 0.13925057,
    "eur": 0.11974298
  }
}

User Interface

Settings Panel

The script provides an intuitive settings interface:

  • Currency Selection: Radio buttons for EUR/USD
  • Rate Display: Shows current exchange rate (1 CNY = X EUR/USD)
  • Auto-save: Preferences saved automatically using GM_setValue()
  • Clean Design: Non-intrusive floating panel

Access Methods

  1. Automatic: Panel shows on page load for 10 seconds
  2. Keyboard: Press Ctrl+Shift+Y anytime
  3. Console: Run YuanConvShowSettings() command
  4. Persistent: Your choice is remembered across sessions

Configuration

Changing Currency

To switch between EUR and USD:

  1. Press Ctrl+Shift+Y to open settings
  2. Select your preferred currency (€ or $)
  3. Settings save automatically and page refreshes
  4. All prices convert to new currency immediately

Changing Exchange Rate Source

To use a different exchange rate API, modify the fetchConversionRate() function:

const response = await fetch('YOUR_API_URL_HERE');

Changing Fallback Rates

Update the fallback rates if needed:

let CONVERSION_RATES = {
    eur: 0.119, // Change EUR fallback rate
    usd: 0.139  // Change USD fallback rate
};

Adding More Websites

To use on other websites, add them to the @match directive:

// @match        *://buff.163.com/*
// @match        *://example.com/*

Development

Script Metadata

  • Name: Yuan Currency Converter
  • Version: 1.2
  • Author: enzomtp
  • Namespace: https://github.com/enzomtpYT/YuanConv
  • Target Site: buff.163.com
  • Grants: GM_setValue, GM_getValue (for persistent settings)

Key Functions

  • fetchConversionRate(): Gets real-time exchange rates for both EUR and USD
  • convertYenToCurrency(): Performs currency conversion based on selected currency
  • getCurrentRate(): Returns current conversion rate for selected currency
  • getCurrencySymbol(): Returns appropriate symbol (€ or $)
  • createSettingsBox(): Creates interactive settings UI
  • showSettings(): Shows/hides settings panel
  • processElement(): Handles HTML-structured prices
  • processTextNode(): Handles simple text prices
  • walkNodes(): Recursively processes page content

Troubleshooting

Script Not Working

  1. Check if the userscript manager is enabled
  2. Verify the script is active for buff.163.com
  3. Check browser console for error messages
  4. Ensure you're on a supported page

Wrong Conversion Rates

  1. Check console for "Updated CNY rates" message with both EUR and USD
  2. Verify API is accessible (check network tab)
  3. If API fails, script uses fallback rates (EUR: 0.119, USD: 0.139)

Settings Not Saving

  1. Ensure Violentmonkey/Tampermonkey has storage permissions
  2. Check that @grant GM_setValue and GM_getValue are enabled
  3. Try clearing userscript storage and reconfiguring

Currency Not Switching

  1. Settings save automatically when you select a currency
  2. Page reloads to apply changes immediately
  3. Check console for "Currency changed to: XXX" message

Prices Not Converting

  1. Check if prices are in the expected format (¥ symbol + numbers)
  2. Some cached content might need a page refresh
  3. Dynamic content should convert automatically
  4. Try pressing Ctrl+Shift+Y to access settings

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test on buff.163.com
  5. Submit a pull request

Support

  • Issues: Report bugs on GitHub Issues
  • Updates: Script auto-updates from GitHub
  • Website: buff.163.com compatibility focused

Changelog

v1.2

  • NEW: Multi-currency support (EUR and USD)
  • NEW: Interactive settings panel with currency selection
  • NEW: Persistent settings using GM_setValue/GM_getValue
  • NEW: Keyboard shortcut (Ctrl+Shift+Y) to show settings
  • NEW: Console command ytoeShowSettings() for quick access
  • IMPROVED: Fetches both EUR and USD rates from API
  • IMPROVED: Auto-reload page when currency changes
  • IMPROVED: Enhanced UI with modern design
  • UPDATED: Script name to "Yuan Currency Converter"

v1.1

  • Added real-time exchange rate fetching
  • Improved HTML structure parsing
  • Added support for decimal prices in <small> tags
  • Enhanced error handling and fallback protection

v1.0

  • Initial release
  • Basic yen to euro conversion
  • Static exchange rate
  • buff.163.com support

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址