OCUK This Week Only Savings % Script

Associate
Joined
24 Jul 2013
Posts
17
Location
Gloucestershire
Had some spare time on my hands, so made the following script that will show the % savings on the This Week Only page.

If you are running Google Chrome, press F12 and go to Console, paste in the following script and hit Enter:

Code:
$prices = $('td tr:has(span.oldprice)');
$prices.each( function() {
    $priceCell = $(this).find('td:has(span.oldprice)');
    var oldPrice = parseFloat($priceCell.find('span.oldprice').text().replace(/£/, ''));
    var newPrice = parseFloat($priceCell.find('span.price').text().replace(/£/, ''));
    var percentSaving = Math.round(100 - (100 / oldPrice * newPrice));
    $priceCell.append($(document.createElement('div')).css('font-size', '16pt').css('color', 'red').text(percentSaving + '%'));
});

You will now see under the price of each item, the percentage saved compared to the original price.

Enjoy!
 
Not wanting to jump on a bandwagon or anything, but if anyone finds it useful I wrote a similar thing to calculate Quidco cashback.

Can be run in the same way but you need to be on the "Your basket" screen:
Code:
$table = document.getElementById("shoppingBkt");
var numRows = $table.rows.length;
var numCellsInLastRow = $table.rows[numRows-1].cells.length;
var totalPrice = parseFloat($table.rows[numRows-1].cells.item(numCellsInLastRow-1).innerHTML.replace(/£/, '').replace(/,/g, ''));
var quidco = (totalPrice * 0.01);
var newRow = $table.rows[numRows-2].cloneNode(true);
newRow.cells[numCellsInLastRow-2].innerHTML = 'Quidco Cashback:';
newRow.cells[numCellsInLastRow-1].innerHTML = "£" + quidco.toFixed(2);
$table.appendChild(newRow);
var newRow2 = $table.rows[numRows-1].cloneNode(true);
newRow2.cells[numCellsInLastRow-2].innerHTML = 'Effective Total:';
newRow2.cells[numCellsInLastRow-1].innerHTML = "£" + (totalPrice - quidco).toFixed(2);
$table.appendChild(newRow2);

EDIT:
Not quite sure how to do bookmarklets but in Firefox if you create a new bookmark and set this as the destination it should work:
Code:
javascript:(function(){$table%20=%20document.getElementById("shoppingBkt");%20var%20numRows%20=%20$table.rows.length;%20var%20numCellsInLastRow%20=%20$table.rows[numRows-1].cells.length;%20var%20totalPrice%20=%20parseFloat($table.rows[numRows-1].cells.item(numCellsInLastRow-1).innerHTML.replace(/%C2%A3/,%20'').replace(/,/g,%20''));%20var%20quidco%20=%20(totalPrice%20*%200.01);%20var%20newRow%20=%20$table.rows[numRows-2].cloneNode(true);%20newRow.cells[numCellsInLastRow-2].innerHTML%20=%20'Quidco%20Cashback:';%20newRow.cells[numCellsInLastRow-1].innerHTML%20=%20"£"%20+%20quidco.toFixed(2);%20$table.appendChild(newRow);%20var%20newRow2%20=%20$table.rows[numRows-1].cloneNode(true);%20newRow2.cells[numCellsInLastRow-2].innerHTML%20=%20'Effective%20Total:';%20newRow2.cells[numCellsInLastRow-1].innerHTML%20=%20"£"%20+%20(totalPrice%20-%20quidco).toFixed(2);%20$table.appendChild(newRow2);})()
 
Last edited:
Ive got an idea for you if you fancy making another:

A script to calculate the £/GB of SSD's

So it can look at the price and the description ***GB and £**.** and calculate the £*.**/GB

:)
 
Back
Top Bottom