-
Notifications
You must be signed in to change notification settings - Fork 1
/
eRepublikUA.js
122 lines (106 loc) · 3.44 KB
/
eRepublikUA.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// ==UserScript==
// @name eRepublik UA
// @version 0.01
// @description Ukrainian tasks
// @author eCitizen Maximko
// @namespace eCitizenMaximko
// @include http://www.erepublik.com/*
// @require http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js
// ==/UserScript==
// Constants
var VERSION = '0.55';
var LOCALE = 'en/'
var BASE_URL = 'http://www.erepublik.com/';
var MAP_URL = 'http://www.eGobba.de/index.htm?nation=';
var RANKS = ['private', 'corporal', 'sergeant', 'lieutenant', 'captain', 'colonel', 'general', 'fieldmarshal'];
var INDUSTRIES = ['', 'Food', 'Gift', 'Weapon', 'Moving Tickets'];
var SKILLS = ['all', 'manufacturing', 'land', 'constructions'];
var TOOLS = ['Badges', 'RSS Feed', 'ThirdParty', 'Forums', 'eRepPlusSettings'];
var SETTINGS_BITS = '11111111111111111111';
var STRINGS = [ 'Swap currencies',
'Link',
'Bold',
'Italic',
'Underline',
'Size',
'Image',
'Damage',
'Empty handed',
'Weapon Quality Level ',
'Top rated news',
'Latest news',
'Military news',
'Please enter ',
'Quick Links ',
'All comments and Translate to ',
'Interactive Map',
'News description',
'"Third Party Tools" and "National Pages and Forums"',
'Wellness calculator on your profile',
'Newspaper and Forum Article Editor',
'Army page displays damage with various quality of weapon',
'Job market filtering ',
'Monetary market "Swap currencies" link',
'Unit price of Products and Raw Materials',
'Wellness shown on All employees page',
'Save Links ',
'Enabled',
'Disabled',
'Num',
'Caption',
'Link',
'New window',
'Third Party Tools',
'National Pages and Forums',
'Plus Settings',
' (All) ',
' Translate ',
'Quality of Hospitals on Social Stats',
'Next Super Soldier Medal Calculator',
'Trainings to next medal: '
];
function calculateUnitPrice() {
alert('test');
var industryIndex = location.href.split('/')[5].split('-')[3];
var unitPrice = 0;
var price = 0;
var quality = 0;
$("table.offers tr").each(function(i) {
if (i != 0)
{
quality = $(this).find("td:eq(1) span span").css("width");
quality = quality.substr(0, quality.length - 1) / 20;
if (quality > 1)
{
price = $(this).find("td:eq(3) span:eq(0)").text() + $(this).find("td:eq(3) sup").text();
unitPrice = (Math.round((price / quality) * 1000) / 1000).toString().split('.');
if (unitPrice[1] == undefined)
unitPrice[1] = '';
else
unitPrice[1] = '.' + unitPrice[1];
$(this).find("td:eq(3) span:eq(1)").after('<br/><span class="special" style="color: #5FAE34;">' + unitPrice[0] + '</span><sup style="color: #5FAE34;">' + unitPrice[1] + '</sup><span class="special"></span>');
}
}
});
}
function Main(e) {
try {
cID = $("div.core div.avatarholder a").attr("href").split('/')[4] + "_";
} catch (e) {}
if (typeof unsafeWindow == 'undefined')
unsafeWindow = window;
var currURL = location.href;
var subURL = currURL.substr(BASE_URL.length);
LOCALE = subURL.substring(0, subURL.indexOf('/')) + '/';
BASE_URL += LOCALE;
subURL = currURL.substr(BASE_URL.length);
var pagesFunctions = [
{p: 'market/', s:8, f: calculateUnitPrice},
];
pagesFunctions.forEach(function(v) {
if ((subURL.substr(0, v.p.length) == v.p) && (getSetting(v.s) != '0' || v.s == '-1'))
v.f();
});
};
var $ = jQuery.noConflict();
window.addEventListener('load', Main, false);