Last active
April 6, 2023 14:11
-
-
Save sertalpbilal/7e8e95345bf573e7834c909fb713efa2 to your computer and use it in GitHub Desktop.
FPLReview Free Model Extraction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let get_all_data = () => { | |
let gws = Array.from(jQuery(".ptsshoq")).map(i => i.textContent).filter(i => i.includes('GW')).map(i => parseInt(i.split('GW')[1])) | |
let first_week = Math.min(...gws) | |
let last_week = Math.max(...gws) | |
let jsondata= jQuery("#fplr_api").text() | |
let d=JSON.parse(decodeURIComponent(escape(window.atob(jsondata)))) | |
let main_keys = ['name', 'pos', 'team_abbrev', 'now_cost', 'now_cost'] | |
let gw_keys = ['dmins', 'livpts'] | |
let text_data = "ID,Name,Pos,Team,BV,SV" | |
for (let w=first_week; w<=last_week; w++) { | |
text_data += `,${w}_xmins,${w}_pts` | |
} | |
let players = Object.entries(d) | |
players = players.filter(i => i[1] != 0) | |
players.forEach(e => { | |
let pid = e[0] | |
let p = e[1] | |
transform_dict = {'pos': (d) => { let v = {'1': 'G', '2': 'D', '3': 'M', '4': 'F'}; return v[d];}, 'now_cost': (d) => parseFloat(d)/10} | |
row_data = pid + "," + main_keys.map(i => transform_dict[i] ? transform_dict[i](p[i]) : p[i]).join(",") | |
for (let w=first_week; w<=last_week; w++) { | |
gw_keys.forEach(k => { | |
try { | |
row_data += ',' + p[w][k] | |
} | |
catch { | |
aa = 1 | |
} | |
}) | |
} | |
text_data += '\n'+row_data | |
}) | |
return text_data | |
} | |
function download_csv_data(csv, filename) { | |
var csvFile; | |
var downloadLink; | |
csvFile = new Blob([csv], {type: "text/csv"}); | |
downloadLink = document.createElement("a"); | |
downloadLink.download = filename; | |
downloadLink.href = window.URL.createObjectURL(csvFile); | |
downloadLink.style.display = "none"; | |
document.body.appendChild(downloadLink); | |
downloadLink.click(); | |
} | |
text_data = get_all_data() | |
download_csv_data(text_data, "fplreview.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $ = jQuery; | |
var atou = (str) => decodeURIComponent(escape(window.atob(str))); | |
var jsondata= $("#fplr_api").html(); | |
var jsonobj=(JSON.parse(atou(jsondata))); | |
$("#fplr_api").html(JSON.stringify(jsonobj)); | |
$('#exportbutton').replaceWith($('#exportbutton').clone()); | |
var script = document.createElement("script") | |
script.src = "https://fplreview.com/wp-content/uploads/TPlitescript/ExportTable_GWdata.js?version=103" | |
document.body.appendChild(script) | |
document.getElementById("exportbutton").parentElement.href = "#" | |
setTimeout(() => {document.getElementById("exportbutton").click()}, 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var script = document.createElement("script") | |
script.src = "https://fplreview.com/wp-content/uploads/TPlitescript/ExportTable_GWdata.js?version=103" | |
document.body.appendChild(script) | |
document.getElementById("exportbutton").parentElement.href = "#" | |
setTimeout(() => {document.getElementById("exportbutton").click()}, 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment