Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
feature: partial update to FIFA 19 web app
Browse files Browse the repository at this point in the history
Includes basic setup to detect new navigation events and includes only Futbin integration.
The other scripts have been disabled until they are updated to the FIFA 19 version

BREAKING CHANGE: This is an update for FIFA 19's version and is not backward compatible
  • Loading branch information
Mardaneus86 committed Sep 22, 2018
1 parent 7eddc63 commit d7bc12c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 48 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![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)

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.
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.

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.
This TamperMonkey script is meant to enhance the FUT 19 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.

Expand All @@ -16,9 +16,6 @@ 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.

## Installation
Make sure you have user scripts enabled in your browser (these instructions refer to the latest versions of the browser):

Expand Down
8 changes: 4 additions & 4 deletions app/core/base-script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global gNavManager */
/* global window */
/* eslint class-methods-use-this: "off" */
import { Settings } from './settings';
import { Database } from './db';
Expand All @@ -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(() => {
Expand All @@ -19,7 +19,7 @@ export class BaseScript {
);

this.activate({
screenId: gNavManager.getCurrentScreen()._screenId,
screenId: window.currentPage,
});
}
});
Expand All @@ -29,7 +29,7 @@ export class BaseScript {
this.screenRequestObserver.unobserve(this);

this.deactivate({
screenId: gNavManager.getCurrentScreen()._screenId,
screenId: window.currentPage,
});
}
});
Expand Down
27 changes: 16 additions & 11 deletions app/futbin/futbin-player-links.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* globals
GM_xmlhttpRequest
gNavManager enums
enums
getAppMain
window $ document
*/
import { BaseScript, Database } from '../core';
Expand Down Expand Up @@ -49,7 +50,7 @@ export class FutbinPlayerLinks extends BaseScript {
if (selectedItem == null || selectedItem.resourceId === 0) {
return;
}
$(mutation.target).find('.DetailPanel ul').append(`<button id="futbinPlayerLink" data-resource-id="${selectedItem.resourceId}" class="list"><span class="btn-text">View on Futbin</span><span class="btn-subtext"></span></button>`);
$(mutation.target).find('.DetailPanel .ut-button-group').append(`<button id="futbinPlayerLink" data-resource-id="${selectedItem.resourceId}" class="list"><span class="btn-text">View on Futbin</span><span class="btn-subtext"></span></button>`);

$('#futbinPlayerLink').bind('click', async () => {
let btn = $('#futbinPlayerLink');
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?
Expand All @@ -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;
}
Expand Down
36 changes: 24 additions & 12 deletions app/futbin/futbin-prices.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* globals
GM_xmlhttpRequest
gNavManager
$
window
getAppMain
*/

import { utils } from '../../fut';
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
35 changes: 23 additions & 12 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* globals models onVisibilityChanged gAuthenticationModel document $ */
/* globals onVisibilityChanged services FUINavigationController UTObservable window document $ */
import 'babel-polyfill';

import initSettingsScreen from './settings';

import { Settings, Queue } from './core';

import { Logger } from '../fut';

/*
import {
CardInfoSettings,
RefreshListSettings,
Expand All @@ -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
Expand All @@ -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);
},
Expand Down
8 changes: 4 additions & 4 deletions fut/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* globals
repositories
services
*/

export default {
Expand All @@ -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';
}

Expand Down

0 comments on commit d7bc12c

Please sign in to comment.