forked from jmasnik/FSEconomyM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFSEconomyM.user.js
131 lines (111 loc) · 5.68 KB
/
FSEconomyM.user.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
123
124
125
126
127
128
129
130
131
// ==UserScript==
// @name FSEconomyM
// @namespace https://github.com/jmasnik/FSEconomyM
// @version 0.2
// @description Script for FSEconomy website
// @author Jiri Masnik
// @match http://server.fseconomy.net/*
// @grant GM_addStyle
// @updateURL https://github.com/jmasnik/FSEconomyM/raw/release/FSEconomyM.meta.js
// @downloadURL https://github.com/jmasnik/FSEconomyM/raw/release/FSEconomyM.user.js
// ==/UserScript==
(function() {
'use strict';
var i;
var el;
var el_block;
var el_cont;
var zp;
var id;
var name;
var css;
// style
css =
"#fsem-settings { width: 400px; height: 330px; position: absolute; left: 150px; top: 140px; line-height: normal; background-color: #fff; border: 1px solid gray; font-size: 14px; z-index: 1000; visibility: hidden; margin:0px; padding:0px; text-align:center; }" +
"#fsem-settings h2 { background-color: gray; color: white; font-size: 15px; padding:4px; text-align:left; }" +
"#fsem-settings textarea { margin: 5px; width: 360px; background-color: #f0f0f0; height:100px; padding: 5px; } " +
"#fsem-settings input { margin: 5px; width: 360px; background-color: #f0f0f0; padding: 5px; color: white; font-weight:bold; background-color: gray; } " +
"#fsem-menu { width: 150px; position: absolute; left: 10px; font-size: 14px; line-height: normal; }" +
"#fsem-menu h2 { display: block; border-bottom: 1px solid gray; color: #000; padding: 3px; font-size: 14px; margin-bottom: 2px; }" +
"#fsem-menu a { display: block; text-decoration: none; color: #3366CC; padding: 3px; } " +
"#fsem-menu a:hover { background-color: #dddddd; }" +
"#fsem-menu .settings { color: #aaa; font-size:11px; cursor: pointer; }" +
"div.footer { display: none !important; }" +
"ul.footer { display: none !important; }";
GM_addStyle(css);
// init local storage
if(localStorage.getItem("fsem_airport_list") === null){
localStorage.setItem("fsem_airport_list", "LKBU@Bubovice;LKCM@Medlánky");
}
if(localStorage.getItem("fsem_aircraft_list") === null){
localStorage.setItem("fsem_aircraft_list", "10191@R-22 (OK-MAY);29080@AS350 (OK-DSW)");
}
// settings dialog
el_block = document.createElement("div");
el_block.id = 'fsem-settings';
el_block.innerHTML = '<h2>FSEconomyM settings</h2>' +
'<textarea id="fsem-settings-v-airports">' + localStorage.getItem("fsem_airport_list") + '</textarea>' +
'<textarea id="fsem-settings-v-aircraft">' + localStorage.getItem("fsem_aircraft_list") + '</textarea>' +
'<input type="button" value=" Save " onclick="localStorage.setItem(\'fsem_airport_list\', document.getElementById(\'fsem-settings-v-airports\').value); localStorage.setItem(\'fsem_aircraft_list\', document.getElementById(\'fsem-settings-v-aircraft\').value); document.location = document.location;">';
document.getElementsByTagName('body')[0].appendChild(el_block);
// airports list
var airport_list = localStorage.getItem("fsem_airport_list").split(";");
// aircraft list
var aircraft_list = localStorage.getItem("fsem_aircraft_list").split(";");
// left menu
var html = "";
if(airport_list.length > 0){
html += "<h2>Airports</h2>";
for(i = 0; i < airport_list.length; i++){
zp = airport_list[i].search('@');
if(zp != -1){
id = airport_list[i].substr(0, zp);
name = airport_list[i].substr(zp + 1, airport_list[i].length);
} else {
id = airport_list[i];
name = airport_list[i];
}
html += '<a href="airport.jsp?icao='+id+'">'+name+'</a>';
}
html += '<br><br>';
}
if(aircraft_list.length > 0){
html += "<h2>Aircraft</h2>";
for(i = 0; i < aircraft_list.length; i++){
zp = aircraft_list[i].search('@');
if(zp != -1){
id = aircraft_list[i].substr(0, zp);
name = aircraft_list[i].substr(zp + 1, aircraft_list[i].length);
html += '<a href="aircraftlog.jsp?id='+id+'">'+ name +'</a>';
}
}
html += '<br><br>';
}
html += '<div onclick="document.getElementById(\'fsem-settings\').style.visibility = \'visible\';" class="settings">Settings</div>';
el_block = document.createElement("div");
el_block.id = "fsem-menu";
el_block.innerHTML = html;
// add menu to page
el = document.getElementById('wrapper');
el.style.marginLeft = '155px';
el.insertBefore(el_block, el.childNodes[0]);
// aircraft page
if(document.location.toString().search('aircraftlog.jsp') != -1){
var table_list = document.getElementsByTagName('TABLE');
var cur_loc_td = table_list[0].childNodes[5].childNodes[0].childNodes[9];
var home_loc_td = table_list[0].childNodes[5].childNodes[0].childNodes[7];
var icao;
var add;
icao = cur_loc_td.innerHTML.substr(0,4);
add = cur_loc_td.innerHTML.substr(4,cur_loc_td.innerHTML.length);
cur_loc_td.innerHTML = '<a href="airport.jsp?icao=' + icao + '">' + icao + '</a>' + add;
icao = home_loc_td.innerHTML.substr(0,4);
add = home_loc_td.innerHTML.substr(4,home_loc_td.innerHTML.length);
home_loc_td.innerHTML = '<a href="airport.jsp?icao=' + icao + '">' + icao + '</a>' + add;
var data_table_list = document.getElementsByClassName("dataTable");
for(i = 0; i < data_table_list.length; i++){
data_table_list[i].style.border = '0px solid gray';
}
}
}
)();