-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtargets.html
214 lines (186 loc) · 7.06 KB
/
targets.html
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>FR13 | Chaining targets</title>
<!-- The style.css file allows you to change the look of your web pages.
If you include the next line in all your web pages, they will all share the same look.
This makes it easier to make new pages for your site. -->
<link href="/style.css" rel="stylesheet" type="text/css" media="all">
<!--<script src="targets.js"></script>-->
<style>
th {
text-align: left;
}
a {
text-decoration: none;
}
a:link, a:visited {
color: blue;
}
a:hover {
color: red;
}
.odd{background-color: white;}
.even{background-color: lightgray;}
</style>
</head>
<!--
TODO:
- CHECKBOX TO AUTOREFRESH EVERY 60SEC
- COOLDOWN FOR THE REFRESH BUTTON ONLY IF 90 API REQUESTS PER MINUTE REACHED
- IF TARGET COUNT >90, PICK ONLY RANDOM 90
- ADD TIMER TO COOLDOWN AND/OR AUTOREFRESH
-->
<body>
<p style="text-align:center">
<a href='index.html'>Home</a> | <strong><a href='targets.html'>Targets</a></strong> | <a href='members.html'>Members</a> | <a href='items.html'>Items</a> | <a href='chainingV2.html'>Chaining (WIP)</a>
</p>
<hr>
<button onclick="buildTable()">Load/Refresh</button>
<!--<button onclick="reloadPage()">Reload page</button> |-->
Your API key:<input id="apiInput" type="text" name="apiKey" value="">
<!--<button id="apiSubmit" onclick="storeAPIKey()">Submit</button> |-->
<input id="cbRefresh" onchange="storeRefreshState()" type="checkbox" name="checkboxState" disabled>Refresh automatically (every 60 seconds)
<!--Add target:<input id="newTarget" type="text" name="targetID" value=""> -->
<!--<button id="targetSubmit" onclick="addTargetID()">Submit</button> | -->
<button id="clearCookies" onclick="clearCookies()">Clear cookies</button>
<!--<a href="admin/login.php" style="appearance: button;text-decoration: none;-webkit-appearance: button;-moz-appearance: button;color: initial;">Login</a>-->
<!--<input type="button" onclick="location.href='admin/login.php';" value="Login" /> -->
<hr>
<table id="targets" style="width:100%">
<thead>
<tr>
<th>Status</th>
<th>Name</th>
<th>Actions</th>
<th>Lvl</th>
<th>HP</th>
<th>Last action</th>
<th>ID</th>
</tr>
<thead>
<tbody>
</tbody>
</table>
<hr>
<p style="text-align:center">
Questions? Ask <a href='https://www.torn.com/profiles.php?XID=2131931#/'>Raith [2131931]</a>.
</p>
<script>
document.getElementById("apiInput").value = readAPIKey();
document.getElementById("cbRefresh").checked = readRefreshState();
var targetListLocation = "names.txt";
function reloadPage () {
window.location.reload(true);
}
function buildTable() {
storeAPIKey();
targets = document.getElementById("targets");
apiKeyValue = document.getElementById("apiInput").value;
rowCount = targets.rows.length;
while(--rowCount) targets.deleteRow(rowCount);
function loadFromFileSync() {
filePath = targetListLocation;
result = null;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", filePath, false);
xmlhttp.send();
if (xmlhttp.status === 200) {
result = xmlhttp.responseText;
return result;
}
}
function loadFromFileAsync() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", targetListLocation, true);
xmlhttp.onload = function() {
if (xmlhttp.readyState === 4) {
if (xmlhttp.status === 200) {
return xmlhttp.responseText;
}
}
};
xmlhttp.send(null);
}
//figure out and switch to Async loading, since Sync is deprecated
//targetIDs = loadFromFileSync().split("\n");
targetIDs = [2123478, 1779574, 1729823, 2089025, 1295571, 1978133, 1861308, 2020427, 2125591, 781650, 2057902, 2014239, 1938932, 1965284];
if (targetIDs == null || targetIDs == "") {
return;
}
if (readAPIKey() <= 0) {
if (apiKeyValue <= 0) {
return;
}
}
targetIDs.forEach(function populateTable(item, index) {
if (item == '' || item == null || item == '\n') {
//console.log("exit used");
return;
}
fetch('https://api.torn.com/user/'+item+'?selections=&key='+readAPIKey())
.then(function(response){return response.json();})
.then(function(myjson){
row = targets.insertRow(1);
row.insertCell(0).innerHTML = myjson.status.description;
row.insertCell(1).innerHTML = myjson.name.link("https://www.torn.com/profiles.php?XID="+item);
row.insertCell(2).innerHTML = "Attack".link("https://www.torn.com/loader.php?sid=attack&user2ID="+item);
row.insertCell(3).innerHTML = myjson.level;
row.insertCell(4).innerHTML = myjson.life.current+"/"+myjson.life.maximum;
row.insertCell(5).innerHTML = myjson.last_action.relative;
row.insertCell(6).innerHTML = item;
alternate('targets');
});
});
}
function setCookie(name, value) {
today = new Date();
expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); // plus 30 days
document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
}
function getCookie(name) {
re = new RegExp(name + "=([^;]+)");
value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
}
function deleteCookie(name) {
today = new Date();
expired = new Date(today.getTime() - 24 * 3600 * 1000);
document.cookie = name + "=null; path=/; expires=" + expired.toGMTString();
}
function clearCookies() {
deleteCookie("apiKey");
deleteCookie("refreshState");
}
function storeRefreshState() {
setCookie("refreshState", document.getElementById("cbRefresh").checked);
}
function readRefreshState() {
return (getCookie("refreshState") == 'true');
}
function storeAPIKey() {
setCookie("apiKey", document.getElementById("apiInput").value);
}
function readAPIKey() {
return getCookie("apiKey");
}
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function alternate(id) {
if (document.getElementsByTagName) {
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for (i = 0; i < rows.length; i++) {
if (i != 0 && i % 2 == 0) {
rows[i]. className = "even";
} else {
rows[i]. className = "odd";
}
}
}
}
</script>
</body>
</html>