Created
July 10, 2009 21:32
-
-
Save natlownes/144832 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Swoopo Ripoff Calculator | |
// @namespace http://*.swoopo.com | |
// @include http://www.swoopo.com/ | |
// ==/UserScript== | |
var spans = document.getElementsByTagName("span"); | |
var priceRe = /^price_index_page_.*/; | |
var earnRe = /^earn_price_index_page_.*/ | |
setInterval( | |
function() { | |
for (i = 0; i < spans.length; i++) { | |
if(spans[i].getAttribute('id') != null && priceRe.exec(spans[i].getAttribute('id'))) { | |
priceSpan = document.getElementById(spans[i].getAttribute('id')); | |
earnSpan = document.getElementById('earn_' + spans[i].getAttribute('id')); | |
if (earnSpan != null) { | |
earnSpan.parentNode.removeChild(earnSpan); | |
} | |
//priceSpan.addEventListener('onchange', updateEarnings, false); | |
priceString = priceSpan.innerHTML; | |
price = parseFloat(priceString.substring(1)); | |
earnings = (price/0.12) * .60; | |
roundedEarnings = Math.round(earnings*Math.pow(10,3))/Math.pow(10,3); | |
//console.log("price: " + priceString + " earnings: $" + roundedEarnings); | |
earningsSpan = document.createElement('span'); | |
earningsSpan.setAttribute('class', 'prd_pricetag'); | |
earningsSpan.setAttribute('id', 'earn_' + spans[i].getAttribute('id')); | |
br = document.createElement('br'); | |
earningsText = document.createTextNode("$" + roundedEarnings); | |
earningsSpan.appendChild(br); | |
earningsSpan.appendChild(earningsText); | |
//priceSpan.parentNode.appendChild(br); | |
priceSpan.parentNode.appendChild(earningsSpan); | |
} | |
} | |
}, | |
5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment