-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHEUpgrade2.user.js
More file actions
79 lines (72 loc) · 2.26 KB
/
HEUpgrade2.user.js
File metadata and controls
79 lines (72 loc) · 2.26 KB
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
// ==UserScript==
// @name HEUpgrade v2
// @namespace http://tampermonkey.net/
// @version 2.0
// @description Upgrade remaining CPUs and HDDs to max
// @author Emin Afroz (Omega on HackerExperience)
// @include https://legacy.hackerexperience.com/hardware*
// @require https://code.jquery.com/jquery-3.2.1.min.js
// @icon http://www.icon100.com/up/3294/256/panda_08.png
// ==/UserScript==
const account = 'ENTERACCHERE';
var totalServers = $(".widget-content.padding > ul > a").length;
var index = 0;
var interval;
$(document).ready(function() {
interval = setInterval(upgrade,1750);
});
function upgrade(){
$('.label.label-info').html("Completed: " + index + "/" + totalServers);
var server = $(".widget-content.padding > ul > a").eq(index);
cpuUnit = server.find(".list-user > small").eq(0).text();
hddUnit = server.find(".list-user > small").eq(1).text();
while(cpuUnit == "4 GHz" && hddUnit == "10 GB" && index < totalServers)
{
index++;
server = $(".widget-content.padding > ul > a").eq(index);
cpuUnit = server.find(".list-user > small").eq(0).text();
hddUnit = server.find(".list-user > small").eq(1).text();
}
if(index >= totalServers)
{
clearInterval(interval);
$('.label.label-info').html("Done :)");
}
else
{
serverID = server.attr('href').replace("?opt=upgrade&id=","").replace("hardware","");
getData('upgrade', serverID);
}
}
//getData('upgrade', link);
function getData(itemToBuy, id){
$.ajax({
type: 'GET',
url: "/hardware?opt=" + itemToBuy + "&id=" + id,
data: {
opt: itemToBuy,
acc: account
},
success: function(data) {
console.log("Success");
postData('cpu','5000','8');
postData('hdd','8000','6');
index++;
}
});
}
//postData('cpu', 8000, 8);
function postData(itemToBuy, itemCost, itemId){
var dataObject = {};
dataObject.acc = account;
dataObject.act = itemToBuy;
dataObject['part-id'] = itemId;
dataObject.price = itemCost;
$.ajax({
type: 'POST',
data: dataObject,
error: function() {
console.log("Already upgraded!");
}
});
}