Advertisement
Guest User

greasemonkey

a guest
Mar 3rd, 2015
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Travian & over
  3. // @namespace   travian
  4. // @description Script for Travian 4 to get some nice informations
  5. // @author      AGF2413
  6. // @include     *.travian.*
  7. // @grant GM_addStyle
  8. // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
  9. // @version     0.1.3
  10. // ==/UserScript==
  11.  
  12. this.$ = this.jQuery = jQuery.noConflict(true);
  13.   $( document ).ready(function() {
  14.     setResourceBar();
  15. });
  16.  
  17. function setResourceBar() {
  18.     //Wood
  19.     $("#stockBarResource1").append("<div class='t&b-rbar'>"+rSpaceLeft("l1")+"<br />"+secondsToTime(rSpaceLeft("l1")/resources.production['l1']*3600)+"</div>");
  20.     //clay
  21.     $("#stockBarResource2").append(rSpaceLeft("l2")+"<br />"+secondsToTime(rSpaceLeft("l2")/resources.production['l2']*3600));
  22.     //iron
  23.     $("#stockBarResource3").append(rSpaceLeft("l3")+"<br />"+secondsToTime(rSpaceLeft("l3")/resources.production['l3']*3600));
  24.     //grain
  25.     $("#stockBarResource4").append(rSpaceLeft("l4")+"<br />"+secondsToTime(rSpaceLeft("l4")/resources.production['l4']*3600));
  26. }
  27.  
  28. function rSpaceLeft(resourceType) {
  29.     return resources.maxStorage[resourceType]-resources.storage[resourceType];
  30. }
  31.  
  32. function secondsToTime(totalSec) {
  33.     console.log("TotalSec:"+totalSec);
  34.     var days = parseInt( totalSec / 86400 ) % 360;
  35.     var hours = parseInt( totalSec / 3600 ) % 24;
  36.     var minutes = parseInt( totalSec / 60 ) % 60;
  37.     var seconds = parseInt(totalSec % 60);
  38.     return days+"d"+hours+"h"+minutes+"m"+seconds+"s";
  39. }
  40. GM_addStyle("#stockBarResource1 { color: red; }");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement