From fc2b8ad145b613772552ac2bb07a935a4ab8d875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Mon, 27 Feb 2023 14:30:43 +0000 Subject: [PATCH] Add 'pccomponentes-price-per-tera.js' --- pccomponentes-price-per-tera.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pccomponentes-price-per-tera.js diff --git a/pccomponentes-price-per-tera.js b/pccomponentes-price-per-tera.js new file mode 100644 index 0000000..a7de475 --- /dev/null +++ b/pccomponentes-price-per-tera.js @@ -0,0 +1,29 @@ +// ==UserScript== +// @name PCComponentes HDD Price per TB +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description AltePCComponentesrnate HDD Price per TB +// @author sergio.am +// @match https://www.pccomponentes.com/discos-duros* +// @icon https://www.google.com/s2/favicons?sz=64&domain=pccomponentes.com +// @require https://code.jquery.com/jquery-3.6.0.min.js +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + const re = /\w+\s/g; + + $('head').append(""); + + $('div#product-grid a').each(function (idx, item) { + var price = parseFloat($(item).data('product-price')); + var name = $(item).data('product-name'); + var tb = parseInt(name.match(/(\d+) ?TB/)[1]); + + var pricePerTb = price / tb; + + $(item).find('.product-card__price-container').append('' + pricePerTb.toFixed(1) + ' €/TB'); + }); +})(); \ No newline at end of file