Created
May 15, 2025 16:06
-
-
Save funivan/40661f80edcc3a07e57fb1d761395441 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Show sale price | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Show sale price | |
| // @author Ivan | |
| // @match https://www.foxtrot.com.ua/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| document.querySelectorAll('.card__body').forEach(body => { | |
| const priceEl = body.querySelector('.card-price') | |
| const discountEl = body.querySelector('.card__bonus') | |
| const titleEl = body.querySelector('.card__title') | |
| const priceValue = priceEl.textContent.replace(/\D/g, ''); | |
| const discountValue = discountEl.textContent.replace(/\D/g, ''); | |
| const winPercent = 100-Math.round((priceValue - discountValue) / priceValue * 100); | |
| titleEl.textContent = `${winPercent}% - ${titleEl.textContent.replace(/\d+%/, '')}`; | |
| console.log(priceValue, discountValue, winPercent); | |
| const size = 10 + winPercent; | |
| priceEl.style.fontSize = size + 'px'; | |
| discountEl.style.fontSize = size + 'px'; | |
| }) | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment