Skip to content

Instantly share code, notes, and snippets.

Created March 19, 2017 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2b5f2576758fe41a02d0a719f2ead9b6 to your computer and use it in GitHub Desktop.
Save anonymous/2b5f2576758fe41a02d0a719f2ead9b6 to your computer and use it in GitHub Desktop.
Xgame production time
// ==UserScript==
// @name XGame
// @namespace xgame-online.com
// @description Helper for XGame
// @include https://xgame-online.com/*
// @version 1
// @grant none
// ==/UserScript==
$(function () {
var timeFormat = (function () {
function num(val) {
val = Math.floor(val);
return val < 10 ? '0' + val : val;
}
return function (ms/**number*/) {
var sec = ms / 1000
, hours = sec / 3600 % 24
, minutes = sec / 60 % 60
, seconds = sec % 60
;
return num(hours) + ":" + num(minutes) + ":" + num(seconds);
};
})();
$('<div/>', {
style: " position: absolute;\
bottom: 10px; right: 10px;\
width: 48px; height:48px;\
background-image:url(/images/starwars/communication_message.png);\
background-repeat: no-repeat;",
click: function () {
document.location.href = '#buildings.php';
setTimeout(function () {
$('.left-res').each(function (i, e, v) {
$(e).children().each(function (i, e, v) {
if ($(e).hasClass('negative') && $(e).hasClass('metal'))
$(e).attr('title', 'Будет доступно через ' + timeFormat(parseInt($(e).text().replace(/\s/g, '')) * (-1) / production[0] * 1000));
if ($(e).hasClass('negative') && $(e).hasClass('crystal'))
$(e).attr('title', 'Будет доступно через ' + timeFormat(parseInt($(e).text().replace(/\s/g, '')) * (-1) / production[0] * 1000));
if ($(e).hasClass('negative') && $(e).hasClass('deuterium'))
$(e).attr('title', 'Будет доступно через ' + timeFormat(parseInt($(e).text().replace(/\s/g, '')) * (-1) / production[0] * 1000));
})
});
}, 2000);
}
}).appendTo("footer");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment