Page 18 of 19

Re: Greasemonkey script to display team data on FPL league page

Posted: 21 Aug 2018, 08:21
by Afunone
Really looking forward to this, nickchild. Thanks very much.

Re: Greasemonkey script to display team data on FPL league page

Posted: 21 Aug 2018, 08:39
by nickchild
Have made good progress, just working on few of the other stats (transfers and chips) and figuring out the best way to calculate if a player appeared in their team's fixture.

I'm also struggling to program the on/off settings that allow users to toggle the stats that are displayed. This is due to the Greasemonkey engine changing how it handles the GM.setValue and GM.getValue events... So at the moment it is simply set up to display everything. If anyone has any experience using these new methods please send me a PM. Failing that, I will relaunch it with all stats visible while I try to build a workaround.

Hopefully should have an update released before the next gameweek...

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 17:40
by nickchild
Hi guys,

I have now updated the script and pushed it to the same location on userscripts, so anyone with it still installed should receive an update (you may need to do this manually if you have not set up automatic updates).

If not you can install it from this link - https://openuserjs.org/install/nickchil ... fo.user.js

Please let me know if you come across any bugs or errors (let me know which browser and extension you are using).

All previous functionality should be there, with the exception of the sortable table. I will look at reimplementing this over the coming days/weeks depending on other time commitments. Also the H2H data isn't in yet, but I'm not sure how widely used this was, apart from being useful to me!

The only stat I am having a problem with at the moment is the 'Played/To Play/Did Not Play' data. I am currently relying on the BPS stat from each players current gameweek, however any player who scored 0 will currently show as 'Did Not Play' as they simply don't appear in the data set. At the moment I have only come across Charlie Austin with 0 for the current gameweek, so bear this in mind when using that information.

If anyone knows where I can access the 'Minutes' data in the API for a given fixture or gameweek, please let me know and I will adjust the code accordingly.

Here's a quick summary of the functionality for clarity and those new to the script;

- Live score will show the gameweek score for each team as the week progresses, while live total adds the live score to the pre-gameweek score
- Captain information shows the active captain (hover for vice-captain)
- Played data will show you how many players that team has left to play during the gameweek (hover to see a breakdown of the specific players)
- Values (team, bank, total) show the current data (ie. including any price rise/increase/transfers)
- Gameweek transfer and transfer cost shows data for the transfers activated for the NEXT gameweek (ie. this count will reset to 0 as soon as a new gameweek starts)
- Chip info shows any chips previously played and those that are active for the current gameweek (an active chip is indicated by a pink highlight)
- Wildcard info shows if the wildcard is still available (ie. a tick shows their wildcard has not been played, while a cross shows it has been - hover over the icon to see which gameweek it was played)
- Squad list can be toggled for each team by clicking the 'T' in the position cell, or by clicking the 'T' at the top of the table to show/hide all squads
- Options at the bottom will turn the associated setting on or off (a refresh is required to update the view). Use the Quick Picks to display data relevant to either Team Info (value, transfer and chip info) or Live Info (live scores, captain, chips, wildard, played). There is also an 'Extra Wide' option if you are displaying all data as the table can get quite squashed otherwise

Due to the way FPL load the league tables, it may be necessary to perform a manual refresh on the page once your league table has initially loaded before the script will execute.

I have only tested this in Firefox (Greasemonkey), but the script 'should' work in the equivilent extensions in Chrome/Safari etc

Enjoy!

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 18:10
by thesilkworm
From a quick test in Chrome, this looks great - thanks! Will be able to test it more thoroughly at the weekend when games are actually live, so will let you know if anything unexpected happens.

Regarding the Charlie Austin problem, how about this?

https://fantasy.premierleague.com/drf/event/2/live

CTRL-F "348" which is his player ID. You'll see that inside this object there's a "minutes": 57 stat. I can't confirm that this would be available while the gameweek is live as have never checked, but from the name of the URL I'd expect so.

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 18:20
by nickchild
Aha! That's perfect. Thanks thesilkworm. I knew it must be somewhere. It looks more reliable than parsing the fixture data as I am currently doing. Where do you find the available API calls? My source is obviously out of date!

Edit: Script updated

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 18:34
by thesilkworm
I have this excellent post from Mav3rick bookmarked:

viewtopic.php?f=18&t=121295#p2911180

It's from two years ago so can't guarantee it's exhaustive or fully up-to-date. I don't think anything's changed though.

What I tend to do when looking for a particular data point is browse to an FPL page that I know must rely on that data point for it to function correctly, then open Chrome dev tools and view the XHR requests. The Points page (e.g. https://fantasy.premierleague.com/a/team/38510/event/2) would need live information on how many minutes Charlie Austin had played mid-game, and sure enough when I check the XHR requests we see that there's a request to https://fantasy.premierleague.com/drf/event/2/live.

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 18:38
by thesilkworm
nickchild wrote: 23 Aug 2018, 18:20 Edit: Script updated
That was fast! Seems to work correctly now.

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 18:53
by nickchild
Lo and behold, I just found a different script that actually had the call to that '/live' method. Turns out I've been editing an older version of the script, pre API calls. The later one had a lot of the code I just re-wrote. I thought I had a weird sense of deja vu whilst coding this latest version....!!!

Just updated the script to show (C) and (vc) in the squad list.

I'll pick my way through the newer old script (!) to see if there was anything else I have missed or was doing better...

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 19:55
by sstaffsw
Works brilliantly for me, thanks for spending the time and effort nickchild.

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 20:34
by jacksosi
Is there some way to use it on an iPhone? Cheers

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 21:09
by nickchild
jacksosi wrote: 23 Aug 2018, 20:34 Is there some way to use it on an iPhone? Cheers
Unfortunately not. No mobile browsers support userscripts. I did have an iOS app in the store up until this season but it's no longer available. It was costing me more to host the API and pay for my dev license than I was earning from it! I may rebuild it at some point...

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 22:06
by MoSe
thesilkworm wrote: 23 Aug 2018, 18:34 I have this excellent post from Mav3rick bookmarked:

viewtopic.php?f=18&t=121295#p2911180

It's from two years ago so can't guarantee it's exhaustive or fully up-to-date. I don't think anything's changed though.
If you browse further in that topic, you'll find that FPL DID change some API URL (handle?) during the season, and there were contributions by RPG and eagle224 to track them.
Which I tried to summarise quoting them in a single post
viewtopic.php?p=3106984#p3106984
You yourself answered to nickchild already for a team line-up in the /picks api

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 22:19
by thesilkworm
Ah great, thanks MoSe - bookmark updated :)

I should really read the whole thread at some point as I’m sure there’s some other stuff I’m not aware of.

Re: Greasemonkey script to display team data on FPL league page

Posted: 23 Aug 2018, 23:12
by Fuzzy
Legend.

I am certain the whole community here appreciates the work you put into this nick.

Just made my mini league management duties simple again!

Re: Greasemonkey script to display team data on FPL league page

Posted: 24 Aug 2018, 19:24
by zomri
Hi Nick,
As you may know i have customised your script when you werent responding to community requests and was able to track where the API changes went. Please let me know if you need any help with this. I have added a funcionality to my version of tracking down if a manager has activated a wc or free hit chip as I think its useful for spying on opponents. Please let me know if tou are interested in adding this feature as well and you need any help.

The one thing that is still bugging me (pun intended) is these page load inconsistencies i get where data is randomly messed up for certain rows. Any chance you experienced the same issue and how to track it down? Any help greatly appreciated.

Re: Greasemonkey script to display team data on FPL league page

Posted: 24 Aug 2018, 19:32
by supersonic
Thanks as always Nick

Re: Greasemonkey script to display team data on FPL league page

Posted: 25 Aug 2018, 12:49
by nickchild
I need to subtract transfer hits from live scores... all seems to be working OK otherwise

Re: Greasemonkey script to display team data on FPL league page

Posted: 25 Aug 2018, 12:57
by Stemania
Is this version 4.0.3 nick?

Re: Greasemonkey script to display team data on FPL league page

Posted: 25 Aug 2018, 13:47
by Afunone
Thanks, Nick. Very grateful.

Here's a screenshot of a little mini-league from about half-time in the Wolves v City game.

Image

It looks to me that 'Total transfers', 'Gameweek transfers' and 'Transfer points hit' are not working. Nearly everyone in that ML has made a transfer this GW (so that's the GWT column), and a few have points hits this GW (TPH column) and Total Transfers is clearly not right.

As an example, number 7 in this ML has made 3 transfers this GW for an 8-point hit. They have made 4 total transfers.

I don't mind at all, just reporting. It's a lovely script just to be able to see captains and squad values etc at a glance. And maybe the errors are to with other factors my end?

FPL get team info 4.0.3
Firefox 61.0.2
Violentmonkey 2.9.5

Re: Greasemonkey script to display team data on FPL league page

Posted: 26 Aug 2018, 23:57
by nickchild
Good spot on the total transfers - I had been checking the chip count value as it wasn't displaying at first and hadn't removed it from that column! Fixed now.

As for the gameweek transfers and hit points - this reflects the transfers executed during the current gameweek (ie. ones that will affect the team in the next gameweek). This info is a bit more useful as the gameweek deadline approaches.

Re: Greasemonkey script to display team data on FPL league page

Posted: 27 Aug 2018, 22:52
by Afunone
Cheers, Nick - and thanks for the update.

Re: Greasemonkey script to display team data on FPL league page

Posted: 01 Sep 2018, 17:21
by From4corners
nickchild wrote: 23 Aug 2018, 17:40 Hi guys,

I have now updated the script and pushed it to the same location on userscripts, so anyone with it still installed should receive an update (you may need to do this manually if you have not set up automatic updates).

If not you can install it from this link - https://openuserjs.org/install/nickchil ... fo.user.js

Please let me know if you come across any bugs or errors (let me know which browser and extension you are using).
Hey Nick, thanks for this!
The update didn't work for me, neither a re-install with the older one still active so reinstalled it from scratch, at least I tried to but receiving a Windows Script Host error (code 800A1391) and not sure how to get this great script back up and running again..

Re: Greasemonkey script to display team data on FPL league page

Posted: 01 Sep 2018, 19:33
by andybarrell
hi Nick thanks for update

2 issues i have found using Chrome

When viewing any of my mini league tables , i then cannot go back to my team by clicking points

I get this when i view my H2H league
Capture.PNG

Re: Greasemonkey script to display team data on FPL league page

Posted: 02 Sep 2018, 08:14
by andybarrell
player history page
Capture5.PNG

Re: Greasemonkey script to display team data on FPL league page

Posted: 04 Sep 2018, 10:40
by sjaugen
I get a host of error messages. On Chrome with Tampermonkey.
Variables not defined, imflicit global variable etc.

I see that the script "activates" (red 1 marker on the top right TM icon in Chrome), but nothing is happening on the GUI side.

Re: Greasemonkey script to display team data on FPL league page

Posted: 06 Sep 2018, 10:45
by nickchild
It's still working OK for me... do you see the options below the table to turn the different data on/off? Are any of these set to 'on'?

Re: Greasemonkey script to display team data on FPL league page

Posted: 06 Sep 2018, 16:48
by sjaugen
Hmm, works now for the first time. Might have been a conflict with Better FPL?
The error (?) messages are still there, but data is flowing in on the league site :)

Re: Greasemonkey script to display team data on FPL league page

Posted: 06 Sep 2018, 17:33
by Stemania
Working for me nc, and working great. Nice work! :D

I also recall having conflicts with BetterFPL before, but disabled it a while ago.

Re: Greasemonkey script to display team data on FPL league page

Posted: 07 Sep 2018, 10:49
by t88
Thx so much nc for this wonderful script! It's been extremely useful in doing analysis and comparing with others in my minileague.

One thing I noticed and this is just reporting it, I'm not complaining :)
I can't insert the screenshot but when displaying my minileague I'm seeing blank values in the following columns for some teams:
Cols: Value, Bank, Total, TT, GWT, TPH, WC, Chips

For other teams, all columns are showing correctly.
Btw I'm using firefox (greasemonkey)

Re: Greasemonkey script to display team data on FPL league page

Posted: 08 Nov 2018, 19:28
by Afunone
Nick, I've only just noticed this but I'm guessing it's been like this all the time ... When I click the little "T" to show the full teams in my minileague, the text runs out of space.

Like this:
Image

I realised because I did a Ctrl+F to find out how many people had Arnautovic and saw that one person who has him appeared not to have him (the 4th person in the league - with "Agüero (C)" at the end of the line). Then I looked closer and saw why. Arnie's name doesn't fit on the page.

All I could think to try was change the zoom scale of the page and refresh but that didn't change anything.

I'm using Violentmonkey on Firefox. Any ideas?