-
Notifications
You must be signed in to change notification settings - Fork 114
/
autobuyermenu.js
374 lines (337 loc) · 18.8 KB
/
autobuyermenu.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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
// ==UserScript==
// @name FUT 20 Autobuyer Menu with TamperMonkey
// @namespace http://tampermonkey.net/
// @version 0.1
// @updateURL https://github.com/chithakumar13/Fifa-AutoBuyer/blob/master/autobuyermenu.js
// @description FUT Snipping Tool
// @author CK Algos
// @match https://www.easports.com/uk/fifa/ultimate-team/web-app/*
// @match https://www.easports.com/fifa/ultimate-team/web-app/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.UTAutoBuyerViewController = function () {
UTMarketSearchFiltersViewController.call(this);
this._jsClassName = "UTAutoBuyerViewController";
}
window.sellList = [];
window.autoBuyerActive = false;
window.activateAutoBuyer = function() {
if (window.autoBuyerActive) {
return;
}
window.autoBuyerActive = true;
window.notify('Autobyer Started');
}
window.deactivateAutoBuyer = function() {
if (!window.autoBuyerActive) {
return;
}
window.autoBuyerActive = false;
window.notify('Autobyer Stopped');
}
utils.JS.inherits(UTAutoBuyerViewController, UTMarketSearchFiltersViewController)
window.UTAutoBuyerViewController.prototype.init = function init() {
if (!this.initialized) {
//getAppMain().superclass(),
this._viewmodel || (this._viewmodel = new viewmodels.BucketedItemSearch),
this._viewmodel.searchCriteria.type === enums.SearchType.ANY && (this._viewmodel.searchCriteria.type = enums.SearchType.PLAYER);
var t = gConfigurationModel.getConfigObject(models.ConfigurationModel.KEY_ITEMS_PER_PAGE)
, count = 1 + (utils.JS.isValid(t) ? t[models.ConfigurationModel.ITEMS_PER_PAGE.TRANSFER_MARKET] : 15);
this._viewmodel.searchCriteria.count = count,
this._viewmodel.searchFeature = enums.ItemSearchFeature.MARKET;
var view = this.getView();
view.addTarget(this, this._eResetSelected, UTMarketSearchFiltersView.Event.RESET),
view.addTarget(this, window.activateAutoBuyer, UTMarketSearchFiltersView.Event.SEARCH),
view.addTarget(this, this._eFilterChanged, UTMarketSearchFiltersView.Event.FILTER_CHANGE),
view.addTarget(this, this._eMinBidPriceChanged, UTMarketSearchFiltersView.Event.MIN_BID_PRICE_CHANGE),
view.addTarget(this, this._eMaxBidPriceChanged, UTMarketSearchFiltersView.Event.MAX_BID_PRICE_CHANGE),
view.addTarget(this, this._eMinBuyPriceChanged, UTMarketSearchFiltersView.Event.MIN_BUY_PRICE_CHANGE),
view.addTarget(this, this._eMaxBuyPriceChanged, UTMarketSearchFiltersView.Event.MAX_BUY_PRICE_CHANGE),
this._viewmodel.getCategoryTabVisible() && (view.initTabMenuComponent(),
view.getTabMenuComponent().addTarget(this, this._eSearchCategoryChanged, enums.Event.TAP)),
this._squadContext ? isPhone() || view.addClass("narrow") : view.addClass("floating"),
view.getPlayerNameSearch().addTarget(this, this._ePlayerNameChanged, enums.Event.CHANGE),
view.__root.style = "width: 50%; float: left;";
}
};
function addTabItem() {
if (jQuery('h1.title').html() == 'Home') {
getAppMain().getRootViewController().showGameView = function showGameView() {
if (this._presentedViewController instanceof UTGameTabBarController)
return !1;
var t, i = new UTGameTabBarController,
s = new UTGameFlowNavigationController,
o = new UTGameFlowNavigationController,
l = new UTGameFlowNavigationController,
u = new UTGameFlowNavigationController,
h = new UTGameFlowNavigationController,
p = new UTTabBarItemView,
_ = new UTTabBarItemView,
g = new UTTabBarItemView,
m = new UTTabBarItemView,
S = new UTTabBarItemView;
if (s.initWithRootController(new UTHomeHubViewController),
o.initWithRootController(new UTSquadsHubViewController),
l.initWithRootController(new UTTransfersHubViewController),
u.initWithRootController(new UTStoreViewController),
h.initWithRootController(new UTClubHubViewController),
p.init(),
p.setTag(UTGameTabBarController.TabTag.HOME),
p.setText(services.Localization.localize("navbar.label.home")),
p.addClass("icon-home"),
_.init(),
_.setTag(UTGameTabBarController.TabTag.SQUADS),
_.setText(services.Localization.localize("nav.label.squads")),
_.addClass("icon-squad"),
g.init(),
g.setTag(UTGameTabBarController.TabTag.TRANSFERS),
g.setText(services.Localization.localize("nav.label.trading")),
g.addClass("icon-transfer"),
m.init(),
m.setTag(UTGameTabBarController.TabTag.STORE),
m.setText(services.Localization.localize("navbar.label.store")),
m.addClass("icon-store"),
S.init(),
S.setTag(UTGameTabBarController.TabTag.CLUB),
S.setText(services.Localization.localize("nav.label.club")),
S.addClass("icon-club"),
s.tabBarItem = p,
o.tabBarItem = _,
l.tabBarItem = g,
u.tabBarItem = m,
h.tabBarItem = S,
t = [s, o, l, u, h],
!isPhone()) {
var C = new UTGameFlowNavigationController,
T = new UTGameFlowNavigationController,
AB = new UTGameFlowNavigationController, //added row
v = new UTGameFlowNavigationController;
C.initWithRootController(new UTSBCHubViewController),
T.initWithRootController(new UTLeaderboardsHubViewController),
AB.initWithRootController(new UTAutoBuyerViewController), //added line
v.initWithRootController(new UTAppSettingsViewController);
var L = new UTTabBarItemView;
L.init(),
L.setTag(UTGameTabBarController.TabTag.SBC),
L.setText(services.Localization.localize("nav.label.sbc")),
L.addClass("icon-sbc");
var I = new UTTabBarItemView;
I.init(),
I.setTag(UTGameTabBarController.TabTag.LEADERBOARDS),
I.setText(services.Localization.localize("nav.label.leaderboards")),
I.addClass("icon-leaderboards");
//added section
var AutoBuyerTab = new UTTabBarItemView;
AutoBuyerTab.init(),
AutoBuyerTab.setTag(8),
AutoBuyerTab.setText('AutoBuyer'),
AutoBuyerTab.addClass("icon-transfer");
var P = new UTTabBarItemView;
P.init(),
P.setTag(UTGameTabBarController.TabTag.SETTINGS),
P.setText(services.Localization.localize("button.settings")),
P.addClass("icon-settings"),
C.tabBarItem = L,
T.tabBarItem = I,
v.tabBarItem = P,
AB.tabBarItem = AutoBuyerTab, //added line
t = t.concat([C, T, v, AB]) //added line
}
return i.initWithViewControllers(t),
i.getView().addClass("game-navigation"),
this.presentViewController(i, !0, function() {
services.URL.hasDeepLinkURL() && services.URL.processDeepLinkURL()
}),
!0
};
getAppMain().getRootViewController().showGameView();
} else {
window.setTimeout(addTabItem ,1000);
}
};
function createAutoBuyerInterface()
{
if (jQuery('h1.title').html() == 'Home') {
window.hasLoadedAll = true;
}
if (window.hasLoadedAll && getAppMain().getRootViewController().getPresentedViewController().getCurrentViewController().getCurrentController()._jsClassName) {
if (!jQuery('.SearchWrapper').length) {
var view = getAppMain().getRootViewController().getPresentedViewController().getCurrentViewController().getCurrentController()._view;
jQuery(view.__root.parentElement).prepend(
'<div id="InfoWrapper" class="ut-navigation-bar-view navbar-style-landscape">' +
' <h1 class="title">AUTOBUYER STATUS: <span id="ab_status"></span> | REQUEST COUNT: <span id="ab_request_count">0</span></h1>' +
' <div class="view-navbar-clubinfo">' +
' <div class="view-navbar-clubinfo-data">' +
' <div class="view-navbar-clubinfo-name">' +
' <div style="float: left;">Search:</div>' +
' <div style="float: right; height: 10px; width: 100px; background: #888; margin: 5px 0px 5px 5px;">' +
' <div id="ab_search_progress" style="background: #000; height: 10px; width: 0%"></div>' +
' </div>' +
' </div>' +
' <div class="view-navbar-clubinfo-name">' +
' <div style="float: left;">Statistics:</div>' +
' <div style="float: right; height: 10px; width: 100px; background: #888; margin: 5px 0px 5px 5px;">' +
' <div id="ab_statistics_progress" style="background: #000; height: 10px; width: 0%"></div>' +
' </div>' +
' </div>' +
' </div>' +
' </div>' +
' <div class="view-navbar-currency" style="margin-left: 10px;">' +
' <div class="view-navbar-currency-coins" id="ab_coins"></div>' +
' </div>' +
' <div class="view-navbar-clubinfo">' +
' <div class="view-navbar-clubinfo-data">' +
' <span class="view-navbar-clubinfo-name">Sold Items: <span id="ab-sold-items"></span></span>' +
' <span class="view-navbar-clubinfo-name">Unsold Items: <span id="ab-unsold-items"></span></span>' +
' </div>' +
' </div>' +
' <div class="view-navbar-clubinfo" style="border: none;">' +
' <div class="view-navbar-clubinfo-data">' +
' <span class="view-navbar-clubinfo-name">Available Items: <span id="ab-available-items"></span></span>' +
' <span class="view-navbar-clubinfo-name">Active transfers: <span id="ab-active-transfers"></span></span>' +
' </div>' +
' </div>' +
'</div>'
);
jQuery(view.__root.parentElement).append('<div id="SearchWrapper" style="width: 50%; right: 50%"><textarea readonly id="progressAutobuyer" style="font-size: 15px; width: 100%;height: 58%;"></textarea><label>Search Results:</label><br/><textarea readonly id="autoBuyerFoundLog" style="font-size: 10px; width: 100%;height: 26%;"></textarea></div>');
writeToLog('Autobuyer Ready');
}
if (jQuery('.search-prices').first().length) {
if (!jQuery('#ab_buy_price').length) {
jQuery('.search-prices').first().append(
'<div class="search-price-header">' +
' <h1 class="secondary">AB Settings:</h1>'+
'</div>' +
'<div class="price-filter">' +
' <div class="info">' +
' <span class="secondary label">Sell Price:</span><br/><small>Recieve After Tax: <span id="sell_after_tax">0</span></small>' +
' </div>' +
' <div class="buttonInfo">' +
' <div class="inputBox">' +
' <input type="tel" class="numericInput" id="ab_sell_price" placeholder="7000">' +
' </div>' +
' </div>' +
'</div>' +
'<div class="price-filter">' +
' <div class="info">' +
' <span class="secondary label">Buy Price:</span>' +
' </div>' +
' <div class="buttonInfo">' +
' <div class="inputBox">' +
' <input type="tel" class="numericInput" id="ab_buy_price" placeholder="5000">' +
' </div>' +
' </div>' +
'</div>' +
'<div class="price-filter">' +
' <div class="info">' +
' <span class="secondary label">Wait Time:<br/><small>(random second range eg. 7-15)</small>:</span>' +
' </div>' +
' <div class="buttonInfo">' +
' <div class="inputBox">' +
' <input type="tel" class="numericInput" id="ab_wait_time" placeholder="7-15">' +
' </div>' +
' </div>' +
'</div>' +
'<div class="price-filter">' +
' <div class="info">' +
' <span class="secondary label">Min clear count:<br/><small>(clear sold items if count is not less than)</small>:</span>' +
' </div>' +
' <div class="buttonInfo">' +
' <div class="inputBox">' +
' <input type="tel" class="numericInput" id="ab_min_delete_count" placeholder="10">' +
' </div>' +
' </div>' +
'</div>' +
'<div class="price-filter">' +
' <div class="info">' +
' <span class="secondary label">Max purchases per search request:</span>' +
' </div>' +
' <div class="buttonInfo">' +
' <div class="inputBox">' +
' <input type="text" class="numericInput" id="ab_max_purchases" placeholder="3">' +
' </div>' +
' </div>' +
'</div>'
);
}
}
if (!jQuery('#search_cancel_button').length) {
jQuery('#InfoWrapper').next().find('.button-container button').first().after('<button class="btn-standard" id="search_cancel_button">Stop</button>')
}
} else {
window.setTimeout(createAutoBuyerInterface, 1000);
}
}
jQuery(document).on('click', '#search_cancel_button', deactivateAutoBuyer);
jQuery(document).on('keyup', '#ab_sell_price', function(){
jQuery('#sell_after_tax').html((jQuery('#ab_sell_price').val() - ((parseInt(jQuery('#ab_sell_price').val()) / 100) * 5)).toLocaleString());
});
window.updateAutoTransferListStat = function() {
if (!window.autoBuyerActive) {
return;
}
window.updateTransferList();
};
window.writeToLog = function(message) {
var $log = jQuery('#progressAutobuyer');
message = "[" + new Date().toLocaleTimeString() + "] " + message + "\n";
$log.val($log.val() + message);
$log.scrollTop($log[0].scrollHeight);
};
window.writeToDebugLog = function(message) {
var $log = jQuery('#autoBuyerFoundLog');
message = "[" + new Date().toLocaleTimeString() + "] " + message + "\n";
$log.val($log.val() + message);
$log.scrollTop($log[0].scrollHeight);
};
window.notify = function(message) {
services.Notification.queue([message, enums.UINotificationType.POSITIVE])
};
window.getRandomWait = function() {
var addedTime = 0;
if (window.searchCount % 15 === 0) {
addedTime = 10000;
}
var wait = [7, 15];
if (jQuery('#ab_wait_time').val() !== '') {
wait = jQuery('#ab_wait_time').val().split('-');
}
window.searchCount++;
return (Math.round((Math.random() * (wait[1] - wait[0]) + wait[0])) * 1000) + 5000 + addedTime;
};
window.getTimerProgress = function (timer) {
var time = (new Date()).getTime();
return (Math.max(0, timer.finish - time) / (timer.finish - timer.start)) * 100;
};
window.updateStatistics = function () {
jQuery('#ab_search_progress').css('width', window.getTimerProgress(window.timers.search));
jQuery('#ab_statistics_progress').css('width', window.getTimerProgress(window.timers.transferList));
jQuery('#ab_request_count').html(window.searchCount);
jQuery('#ab_coins').html(window.futStatistics.coins);
if (window.autoBuyerActive) {
jQuery('#ab_status').css('color', '#2cbe2d').html('RUNNING');
} else {
jQuery('#ab_status').css('color', 'red').html('IDLE');
}
jQuery('#ab-sold-items').html(window.futStatistics.soldItems);
jQuery('#ab-unsold-items').html(window.futStatistics.unsoldItems);
jQuery('#ab-available-items').html(window.futStatistics.availableItems);
jQuery('#ab-active-transfers').html(window.futStatistics.activeTransfers);
if (window.futStatistics.unsoldItems) {
jQuery('#ab-unsold-items').css('color', 'red');
} else {
jQuery('#ab-unsold-items').css('color', '');
}
if (window.futStatistics.availableItems) {
jQuery('#ab-available-items').css('color', 'orange');
} else {
jQuery('#ab-available-items').css('color', '');
}
};
window.hasLoadedAll = false;
window.searchCount = 0;
createAutoBuyerInterface();
addTabItem();
})();