Skip to content

Instantly share code, notes, and snippets.

@funivan
Created May 15, 2025 16:06
Show Gist options
  • Select an option

  • Save funivan/40661f80edcc3a07e57fb1d761395441 to your computer and use it in GitHub Desktop.

Select an option

Save funivan/40661f80edcc3a07e57fb1d761395441 to your computer and use it in GitHub Desktop.
// ==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