Created
November 21, 2012 03:43
-
-
Save dwiash/4122883 to your computer and use it in GitHub Desktop.
Display total earning in every envato marketplace item page
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 Display total earning in every envato marketplace item page | |
// @include http://codecanyon.net/* | |
// @include http://activeden.net/* | |
// @include http://audiojungle.net/* | |
// @include http://themeforest.net/* | |
// @include http://videohive.net/* | |
// @include http://graphicriver.net/* | |
// @include http://3docean.net/* | |
// @include http://marketplace.tutsplus.com/* | |
// @include http://photodune.net/* | |
// ==/UserScript== | |
function hitung() { | |
jQuery(document).ready(function(){ | |
var salesInIDR = jQuery('.price_in_dollars').html() * jQuery('.comments-purchases > p > span').html() * 0.5 * 9000; | |
var from = jQuery('#item_attributes .attr-detail').first().html(); | |
function addCommas(nStr) { | |
nStr += ''; | |
var x = nStr.split('.'); | |
var x1 = x[0]; | |
var x2 = x.length > 1 ? '.' + x[1] : ''; | |
var rgx = /(\d+)(\d{3})/; | |
while (rgx.test(x1)) { | |
x1 = x1.replace(rgx, '$1' + '.' + '$2'); | |
} | |
return x1 + x2; | |
} | |
jQuery('.pricebox').before('<div class="content-box vertical-space" style="background: white; box-shadow: 0px 0px 15px #FA0; border: none;"> <div class="page-title" style="float:none;font-size: 24px;">Rp. '+addCommas(salesInIDR)+',-</div>since '+from+' </div>'); | |
}); | |
} | |
// a function that loads jQuery and calls a callback function when jQuery has finished loading | |
// (c) http://stackoverflow.com/questions/2246901/include-jquery-inside-greasemonkey-script-under-google-chrome | |
function addJQuery(callback) { | |
var script = document.createElement("script"); | |
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"); | |
script.addEventListener('load', function() { | |
var script = document.createElement("script"); | |
script.textContent = "(" + callback.toString() + ")();"; | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); | |
} | |
// load jQuery and execute the main function | |
addJQuery(hitung); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment