diff --git a/README.md b/README.md index a8cc7ab..09e5c10 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,11 @@ [![Join the chat at https://gitter.im/futwebapp-tampermonkey/Lobby](https://badges.gitter.im/futwebapp-tampermonkey/Lobby.svg)](https://gitter.im/futwebapp-tampermonkey/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -:bangbang: This script does not work in the FIFA 19 web app (yet), since the underlying code on which this script relies has changed quite extensively. It is advisable to disable the script until further notice. +FIFA 19's companion app for FIFA Ultimate Team, the FUT 19 Web App, is a website that let's you trade and manage your team on the go. -FIFA 18's companion app for FIFA Ultimate Team, the FUT 18 Web App, is a website that let's you trade and manage your team on the go. +This TamperMonkey script is meant to enhance the FUT 19 Web App experience. You can install the script following the instructions below. Afterwards you will get a settings button on the bottom right of the web app, where you can enable every feature by itself. The script provides a certain degree of customization possibilities. -This TamperMonkey script is meant to enhance the FUT 18 Web App experience. You can install the scripts following the instructions below. Afterwards you will get a settings button on the bottom right of the web app, where you can enable every feature by itself. The scripts provide a certain degree of customization possibilities. - -:warning: Using these scripts is at your own risk. EA might (temp-)ban you for automating parts of their Web App. +:warning: Using this script is at your own risk. EA might (temp-)ban you for automating parts of their Web App. :bangbang: Do not request autobuyer features. Because they are considered to be cheating, it will not be added. @@ -18,8 +16,14 @@ If you benefit from this project, you can buy me a beer :beers: :+1: [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=VTXU8XUY8JS94) -## Separate scripts -To find the old version of the scripts that you could install separately, please refer to the [separate-scripts tag](https://github.com/Mardaneus86/futwebapp-tampermonkey/tree/separate-scripts). Keep in mind that those scripts are no longer actively maintained. +## FIFA 19 working features +- [x] Futbin integration +- [ ] Find Min BIN +- [ ] Relist expired auctions +- [ ] Remove sold items +- [ ] Refresh transfer list +- [ ] Increase transfer list size +- [ ] Download all players in club ## Installation Make sure you have user scripts enabled in your browser (these instructions refer to the latest versions of the browser): diff --git a/app/core/base-script.js b/app/core/base-script.js index 189dd33..06feebf 100644 --- a/app/core/base-script.js +++ b/app/core/base-script.js @@ -1,4 +1,4 @@ -/* global gNavManager */ +/* global window */ /* eslint class-methods-use-this: "off" */ import { Settings } from './settings'; import { Database } from './db'; @@ -9,7 +9,7 @@ export class BaseScript { Settings.getInstance().on('entry-enabled', (entry) => { if (entry.id === id) { - this.screenRequestObserver = gNavManager.onScreenRequest.observe( + this.screenRequestObserver = window.onPageNavigation.observe( this, function (obs, event) { setTimeout(() => { @@ -19,7 +19,7 @@ export class BaseScript { ); this.activate({ - screenId: gNavManager.getCurrentScreen()._screenId, + screenId: window.currentPage, }); } }); @@ -29,7 +29,7 @@ export class BaseScript { this.screenRequestObserver.unobserve(this); this.deactivate({ - screenId: gNavManager.getCurrentScreen()._screenId, + screenId: window.currentPage, }); } }); diff --git a/app/futbin/futbin-player-links.js b/app/futbin/futbin-player-links.js index 32635e0..de097d7 100644 --- a/app/futbin/futbin-player-links.js +++ b/app/futbin/futbin-player-links.js @@ -1,6 +1,7 @@ /* globals GM_xmlhttpRequest -gNavManager enums +enums +getAppMain window $ document */ import { BaseScript, Database } from '../core'; @@ -49,7 +50,7 @@ export class FutbinPlayerLinks extends BaseScript { if (selectedItem == null || selectedItem.resourceId === 0) { return; } - $(mutation.target).find('.DetailPanel ul').append(``); + $(mutation.target).find('.DetailPanel .ut-button-group').append(``); $('#futbinPlayerLink').bind('click', async () => { let btn = $('#futbinPlayerLink'); @@ -81,11 +82,11 @@ export class FutbinPlayerLinks extends BaseScript { let futbinPlayerIds = Database.getJson('futbin-player-ids', []); const futbinPlayer = futbinPlayerIds.find(i => i.id === item.resourceId); if (futbinPlayer != null) { - return resolve(`https://www.futbin.com/18/player/${futbinPlayer.futbinId}`); + return resolve(`https://www.futbin.com/19/player/${futbinPlayer.futbinId}`); } const name = `${item._staticData.firstName} ${item._staticData.lastName}`.replace(' ', '+'); - const url = `https://www.futbin.com/search?year=18&term=${name}`; + const url = `https://www.futbin.com/search?year=19&term=${name}`; return GM_xmlhttpRequest({ method: 'GET', url, @@ -113,7 +114,7 @@ export class FutbinPlayerLinks extends BaseScript { }); } Database.setJson('futbin-player-ids', futbinPlayerIds); - return resolve(`https://www.futbin.com/18/player/${exactPlayers[0].id}`); + return resolve(`https://www.futbin.com/19/player/${exactPlayers[0].id}`); } return resolve(null); // TODO: what should we do if we find more than one? @@ -124,14 +125,18 @@ export class FutbinPlayerLinks extends BaseScript { /* eslint-disable class-methods-use-this */ _getSelectedItem() { - if (gNavManager.getCurrentScreenController()._controller._listController) { - return gNavManager.getCurrentScreenController()._controller._listController - .getIterator().current(); + const listController = getAppMain().getRootViewController() + .getPresentedViewController().getCurrentViewController() + .getCurrentController()._listController; + if (listController) { + return listController.getIterator().current(); } - if (gNavManager.getCurrentScreenController()._controller._rightController._currentController) { - const current = gNavManager.getCurrentScreenController()._controller._rightController - ._currentController._viewmodel.current(); + const currentController = getAppMain().getRootViewController() + .getPresentedViewController().getCurrentViewController() + .getCurrentController()._rightController._currentController; + if (currentController) { + const current = currentController._viewmodel.current(); return current._item ? current._item : current; } diff --git a/app/futbin/futbin-prices.js b/app/futbin/futbin-prices.js index e2f83d1..ee87965 100644 --- a/app/futbin/futbin-prices.js +++ b/app/futbin/futbin-prices.js @@ -1,7 +1,8 @@ /* globals GM_xmlhttpRequest -gNavManager $ +window +getAppMain */ import { utils } from '../../fut'; @@ -35,22 +36,32 @@ export class FutbinPrices extends BaseScript { } _show(screen) { - const showFutbinPricePages = ['WatchList', 'MyClubSearchFilters', 'UnassignedItems', 'TradePile', 'MyClubSearch', 'SearchResults']; + const showFutbinPricePages = [ + 'UTTransferListSplitViewController', // transfer list + 'UTWatchListSplitViewController', // transfer targets + 'UTUnassignedItemsSplitViewController', // pack buy + 'ClubSearchResultsSplitViewController', // club + 'UTMarketSearchResultsSplitViewController', // market search + ]; if (showFutbinPricePages.indexOf(screen) !== -1) { if (this._intervalRunning) { clearInterval(this._intervalRunning); } this._intervalRunning = setInterval(() => { - if (showFutbinPricePages.indexOf(gNavManager._currentScreen._screenId) === -1) { + if (showFutbinPricePages.indexOf(window.currentPage) === -1) { if (this._intervalRunning) { clearInterval(this._intervalRunning); } return; } - const controller = gNavManager.getCurrentScreenController()._controller; + const controller = getAppMain().getRootViewController() + .getPresentedViewController().getCurrentViewController() + .getCurrentController(); - const uiItems = gNavManager.getCurrentScreen().$_root.find('.listFUTItem'); + const uiItems = $(getAppMain().getRootViewController() + .getPresentedViewController().getCurrentViewController() + ._view.__root).find('.listFUTItem'); const targetForButton = uiItems.find('.auction'); if (targetForButton !== null) { @@ -62,7 +73,7 @@ export class FutbinPrices extends BaseScript { } let listController = null; - if (screen === 'UnassignedItems' || screen === 'WatchList') { + if (screen === 'UTUnassignedItemsSplitViewController' || screen === 'UTWatchListSplitViewController') { if (!controller || !controller._leftController || !controller._leftController._view) { @@ -109,7 +120,7 @@ export class FutbinPrices extends BaseScript { }); }); - const futbinUrl = `https://www.futbin.com/18/playerPrices?player=&all_versions=${ + const futbinUrl = `https://www.futbin.com/19/playerPrices?player=&all_versions=${ resourceIdMapping .map(i => i.playerId) .filter((current, next) => current !== next) @@ -161,11 +172,12 @@ export class FutbinPrices extends BaseScript { } const futbinText = 'Futbin BIN'; - switch (gNavManager.getCurrentScreen()._screenId) { - case 'UnassignedItems': - case 'TradePile': - case 'MyClubSearch': - case 'WatchList': + switch (window.currentPage) { + case 'UTTransferListSplitViewController': + case 'UTWatchListSplitViewController': + case 'UTUnassignedItemsSplitViewController': + case 'ClubSearchResultsSplitViewController': + case 'UTMarketSearchResultsSplitViewController': $('.secondary.player-stats-data-component').css('float', 'left'); targetForButton = target.find('.auction'); targetForButton.show(); diff --git a/app/index.js b/app/index.js index 8b714e3..b9ac9bc 100644 --- a/app/index.js +++ b/app/index.js @@ -1,4 +1,4 @@ -/* globals models onVisibilityChanged gAuthenticationModel document $ */ +/* globals onVisibilityChanged services FUINavigationController UTObservable window document $ */ import 'babel-polyfill'; import initSettingsScreen from './settings'; @@ -6,7 +6,7 @@ import initSettingsScreen from './settings'; import { Settings, Queue } from './core'; import { Logger } from '../fut'; - +/* import { CardInfoSettings, RefreshListSettings, @@ -15,17 +15,28 @@ import { MinBinSettings, ListSizeSettings, } from './transferlist'; - +*/ import { FutbinSettings, } from './futbin'; +/* import { ClubInfoSettings, } from './club'; +*/ + +window.onPageNavigation = new UTObservable(); +window.currentPage = ''; + +FUINavigationController.prototype.didPush = (t) => { + if (t) { + window.onPageNavigation.notify(t.className); + window.currentPage = t.className; + } +}; -gAuthenticationModel.addListener( - models.AuthenticationModel.EVENT_AUTHENTICATION_SUCCESSFUL, +services.Authentication._oAuthentication.observe( this, () => { // reset the logs at startup @@ -40,15 +51,15 @@ gAuthenticationModel.addListener( document.removeEventListener('visibilitychange', onVisibilityChanged); const settings = Settings.getInstance(); - settings.registerEntry(new RefreshListSettings()); - settings.registerEntry(new RemoveSoldAuctionsSettings()); - settings.registerEntry(new RelistAuctionsSettings()); - settings.registerEntry(new MinBinSettings()); - settings.registerEntry(new CardInfoSettings()); - settings.registerEntry(new ListSizeSettings()); + // settings.registerEntry(new RefreshListSettings()); + // settings.registerEntry(new RemoveSoldAuctionsSettings()); + // settings.registerEntry(new RelistAuctionsSettings()); + // settings.registerEntry(new MinBinSettings()); + // settings.registerEntry(new CardInfoSettings()); + // settings.registerEntry(new ListSizeSettings()); settings.registerEntry(new FutbinSettings()); - settings.registerEntry(new ClubInfoSettings()); + // settings.registerEntry(new ClubInfoSettings()); initSettingsScreen(settings); }, diff --git a/fut/utils.js b/fut/utils.js index 0669e3c..cb58d86 100644 --- a/fut/utils.js +++ b/fut/utils.js @@ -1,5 +1,5 @@ /* globals -repositories +services */ export default { @@ -16,13 +16,13 @@ export default { }, getPlatform() { - if (repositories.User.getCurrent().getSelectedPersona().isPlaystation) { + if (services.User.getUser().getSelectedPersona().isPlaystation) { return 'ps'; } - if (repositories.User.getCurrent().getSelectedPersona().isPC) { + if (services.User.getUser().getSelectedPersona().isPC) { return 'pc'; } - if (repositories.User.getCurrent().getSelectedPersona().isXbox) { + if (services.User.getUser().getSelectedPersona().isXbox) { return 'xbox'; }