CZK to EUR Converter for bazos.cz

Convert prices from CZK to EUR on bazos.cz using a configurable exchange rate

Author
Potter's 3D Prints
Daily installs
0
Total installs
1
Ratings
0 0 0
Version
0.3
Created
2024-07-21
Updated
2024-07-21
License
MIT
Applies to

CZK to EUR Converter for bazos.cz

Description

This userscript automatically converts prices from CZK (Czech Koruna) to EUR (Euro) on the website bazos.cz. It uses a configurable exchange rate which can be set by the user upon loading the page. The converted prices are displayed alongside the original prices for easy comparison.

Features

  • Converts prices displayed in CZK to EUR using a configurable exchange rate.
  • Displays the converted EUR price next to the original CZK price.
  • Prompts the user to set the exchange rate when the page loads.
  • Automatically updates the prices when the page loads.

Installation

  1. Install a userscript manager for your browser (e.g., Tampermonkey or Violentmonkey).
  2. Click on the "Install this script" button.
  3. Confirm the installation in your userscript manager.

Usage

  1. Go to bazos.cz.
  2. You will be prompted to enter the exchange rate for CZK to EUR.
  3. The prices on the website will automatically be converted to EUR and displayed next to the original CZK prices using the entered exchange rate.

Source Code

// ==UserScript==
// @name         CZK to EUR Converter for bazos.cz
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Convert prices from CZK to EUR on bazos.cz using a configurable exchange rate
// @author       Adam
// @match        https://*.bazos.cz/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Default exchange rate:  = 0.040 EUR
    let exchangeRate = 0.040;

    // Prompt user to set the exchange rate
    const userRate = prompt("Enter the exchange rate for CZK to EUR:", exchangeRate);
    if (!isNaN(parseFloat(userRate)) && isFinite(userRate)) {
        exchangeRate = parseFloat(userRate);
    }

    // Function to convert price from CZK to EUR and update the DOM
    function convertPrices() {
        const priceElements = document.querySelectorAll('.inzeratycena b, tr td b');

        priceElements.forEach(element => {
            const priceText = element.textContent.trim();
            const priceCZK = parseFloat(priceText.replace(/[^0-9]/g, ''));
            if (!isNaN(priceCZK)) {
                const priceEUR = (priceCZK * exchangeRate).toFixed(2);
                element.textContent = `${priceCZK} Kč (${priceEUR} €)`;
            }
        });
    }

    // Convert prices once the page loads
    window.addEventListener('load', convertPrices);
})();

Changelog

Version 0.3

  • Added functionality to prompt the user to set the exchange rate.

Version 0.2

  • Initial release with fixed exchange rate conversion.

Author

  • Adam