-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathsetup.js
More file actions
173 lines (152 loc) · 6.8 KB
/
setup.js
File metadata and controls
173 lines (152 loc) · 6.8 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
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
/* Setup autofarm in the window object */
class ModernBot {
constructor() {
this.console = new BotConsole();
this.storage = new ModernStorage();
this.$ui = $("#ui_box");
// Create the quick menu and the divider element
this.$menu = this.createModernMenu();
const $divider = $('<div class="divider"></div>');
// Add AutoFarm to the new menu
this.autoFarm = new AutoFarm(this.console, this.storage);
this.$menu.append(this.autoFarm.$activity)
this.$ui.append(this.autoFarm.$popup)
//const $farm = this.createActivity("url(https://gpit.innogamescdn.com/images/game/premium_features/feature_icons_2.08.png) no-repeat 0 -240px");
// this.$menu.append($farm, $divider.clone());
this.autoGratis = new AutoGratis(this.console, this.storage);
this.autoRuralLevel = new AutoRuralLevel(this.console, this.storage);
this.autoBuild = new AutoBuild(this.console, this.storage);
this.autoRuralTrade = new AutoRuralTrade(this.console, this.storage);
this.autoBootcamp = new AutoBootcamp(this.console, this.storage);
this.autoParty = new AutoParty(this.console, this.storage);
this.autoTrain = new AutoTrain(this.console, this.storage);
this.autoHide = new AutoHide(this.console, this.storage);
this.antiRage = new AntiRage(this.console, this.storage);
this.autoTrade = new AutoTrade(this.console, this.storage);
this.settingsFactory = new createGrepoWindow({
id: 'MODERN_BOT',
title: 'ModernBot',
size: [845, 300],
tabs: [
{
title: 'Farm',
id: 'farm',
render: this.settingsFarm,
},
{
title: 'Build',
id: 'build',
render: this.settingsBuild,
},
{
title: 'Train',
id: 'train',
render: this.settingsTrain,
} /*
{
title: 'Trade',
id: 'trade',
render: this.settingsTrade,
},*/,
{
title: 'Mix',
id: 'mix',
render: this.settingsMix,
},
{
title: 'Console',
id: 'console',
render: this.console.renderSettings,
},
],
start_tab: 0,
});
this.setup();
}
settingsFarm = () => {
let html = '';
// html += this.autoFarm.settings();
html += this.autoRuralLevel.settings();
html += this.autoRuralTrade.settings();
return html;
};
settingsBuild = () => {
let html = '';
html += this.autoGratis.settings();
html += this.autoBuild.settings();
return html;
};
settingsMix = () => {
let html = '';
html += this.autoBootcamp.settings();
html += this.autoParty.settings();
html += this.autoHide.settings();
return html;
};
settingsTrain = () => {
let html = '';
html += this.autoTrain.settings();
return html;
};
settingsTrade = () => {
let html = ``;
html += this.autoTrade.settings();
return html;
};
setup = () => {
/* Activate */
this.settingsFactory.activate();
uw.$('.gods_area_buttons').append("<div class='circle_button modern_bot_settings' onclick='window.modernBot.settingsFactory.openWindow()'><div style='width: 27px; height: 27px; background: url(https://raw.githubusercontent.com/Sau1707/ModernBot/main/img/gear.png) no-repeat 6px 5px' class='icon js-caption'></div></div>");
/* Add event to polis list menu */
const editController = () => {
const townController = uw.layout_main_controller.sub_controllers.find(controller => controller.name === 'town_name_area');
if (!townController) {
setTimeout(editController, 2500);
return;
}
const oldRender = townController.controller.town_groups_list_view.render;
townController.controller.town_groups_list_view.render = function () {
oldRender.call(this);
const both = `<div style='position: absolute; background-image: url(https://raw.githubusercontent.com/Sau1707/ModernBot/main/img/hammer_wrench.png); background-size: 19px 19px; margin: 1px; background-repeat: no-repeat; position: absolute; height: 20px; width: 25px; right: 18px;'></div>`;
const build = `<div style='background-image: url(https://raw.githubusercontent.com/Sau1707/ModernBot/main/img/hammer_only.png); background-size: 19px 19px; margin: 1px; background-repeat: no-repeat; position: absolute; height: 20px; width: 25px; right: 18px;'></div>`;
const troop = `<div style='background-image: url(https://raw.githubusercontent.com/Sau1707/ModernBot/main/img/wrench.png); background-size: 19px 19px; margin: 1px; background-repeat: no-repeat; position: absolute; height: 20px; width: 25px; right: 18px;'></div>`;
const townIds = Object.keys(uw.modernBot.autoBuild.towns_buildings);
const troopsIds = uw.modernBot.autoTrain.getActiveList().map(entry => entry.toString());
uw.$('.town_group_town').each(function () {
const townId = parseInt(uw.$(this).attr('data-townid'));
const is_build = townIds.includes(townId.toString());
const id_troop = troopsIds.includes(townId.toString());
if (!id_troop && !is_build) return;
if (id_troop && !is_build) uw.$(this).prepend(troop);
else if (is_build && !id_troop) uw.$(this).prepend(build);
else uw.$(this).prepend(both);
});
};
};
setTimeout(editController, 2500);
};
/* New quick menu */
// Create the html of an activity in the new quick menu
createModernMenu = () => {
const $menu = $('<div id="modern_menu" class="toolbar_activities"></div>');
$menu.css({
'position': 'absolute',
'top': '3px',
'left': '400px',
'z-index': '1000',
});
// Add left, middle, right
const $left = $('<div class="left"></div>');
const $middle = $('<div class="middle"></div>');
const $right = $('<div class="right"></div>');
$menu.append($left, $middle, $right);
$("#ui_box").prepend($menu);
return $middle
}
}
// Load the bot when the loader is ready
const loader = setInterval(() => {
if ($("#loader").length > 0) return;
uw.modernBot = new ModernBot();
clearInterval(loader);
}, 100);