Mary Briskin

Google Chrome Prank Extension

Next Cyber Monday will be a blast.

Confused Shopper is a Chrome extension that changes all of the prices on your page to appear to be between $0.01 and $0.99. Secretly upload it to a friend's computer and enjoy their reaction when they discover the great new deals of the day.


This was my first Chrome Extension so to get started, I read through Google's tutorial
To capture all of the prices on the page I used a regular expression, to access and change them I used Javascript's String replace() method and innerHTML method.
function activate() {
  // captures all of the prices on the page
  var prices = /[$](\.|\,|\d+)+/g;
  //replaces them with randomly generated prices
  document.body.innerHTML = document.body.innerHTML.replace(prices, randomPrice);
}


Lessons Learned:
  1. Calling the Javascript String replace() method with a function
  2. Regular Expressions for a repeating patterns
  3. Basic setup of a Chrome extension


Issues:

  1. Something like '$5 billion' would turn into something like '$0.45 billion', which looks silly.
  2. Since prices are randomly generated, if a page displays the price of a single item twice the two values will likely be different.


Fixes/additional features to add:

  1. Include conditions for the words 'billion, million, hundred' etc. and change accordingly.
  2. Keep equal prices equal (i.e. $10 and $10 will equal $0.22 and $0.22). 
  3. Let users choose the range of prices they want to display.
  4. Add functionality for turning the extension off
  5. Including a safeguard to keep people from actually buying anything when they are unaware of the real price.


Get the Confused Shopper Extension HERE.