Add 'alternate-price-per-tera.js'
This commit is contained in:
parent
e40c4b9e20
commit
ef910e63c4
|
@ -0,0 +1,29 @@
|
|||
// ==UserScript==
|
||||
// @name Alternate HDD Price per TB
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 0.1
|
||||
// @description Alternate HDD Price per TB
|
||||
// @author sergio.am
|
||||
// @match https://www.alternate.es/Discos-duros*
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=alternate.es
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const re = /\w+\s/g;
|
||||
|
||||
$('head').append("<style>.pricePerTb { color:blue; padding-left: 20px; }</style>");
|
||||
|
||||
$('.grid-container.listing a.card').each(function (idx, item) {
|
||||
var price = parseFloat($(item).find('span.price').text().replace('€', ''));
|
||||
var name = $(item).find('div.product-name').text();
|
||||
var cap = $(item).find('ul.product-info li:first-of-type').text();
|
||||
var tb = parseInt(cap.match(/Capacidad: (\d+) TB/)[1]);
|
||||
|
||||
var pricePerTb = price / tb;
|
||||
|
||||
$(item).find('span.price').append('<span class="pricePerTb">' + pricePerTb.toFixed(1) + ' €/TB</span>');
|
||||
});
|
||||
})();
|
Loading…
Reference in New Issue