Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit a637ada

Browse files
authored
Add extension (#2)
* Add extension * Fix manifest * Add link to ladders * Fix auto addition * Fix plugin installation * Bump extension version * Add legal warn * Remember last choice --------- Co-authored-by: marqdevx <[email protected]>
1 parent eb00364 commit a637ada

File tree

4 files changed

+285
-1
lines changed

4 files changed

+285
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
# Filter-ESEA-League
22
Filter teams on the ESEA's ranking webpage, javascript to filter the teams of an specific country and set colors if they are qualified for playoffs
33

4+
>The name ESEA is a trademark of ESL Gaming Online, Inc.
5+
>Tis a third-party browser extension and is not affiliated with ESEA or ESL Gaming Online, Inc.
6+
>Use it under your responsability
7+
48
## Features
59
* Only needs to be run once, everytime it detects a division change, refreshes itself.
610
* Color feedback for teams qualified/unqualified for playoffs, depending on the ladder ranking.
711
* Working for every past season (Ony for Challenger, Advanced, Main, Intermdiate and Open divisions).
812

913
## How it works
10-
* It will filter all the teams, and show colors depending on the state of the team
14+
* It will filter all the teams, and show colors depending on the state of the team.
15+
1116
* Green = qualified for playoffs
1217
* Red = not qualified for playoffs
1318
* Choose a country to show **only** the teams from that specific country.
1419

1520
## How to run it
21+
### Extension
22+
Install the extension and forget to run the script, it will auto load once you are on the https://play.esea.net/league/standings page.
23+
24+
You can find the extension on [Firefox Add-ons platform](https://addons.mozilla.org/firefox/addon/esea-filter/)
25+
1626
### Console
1727
1. Copy the content of the `esea-league-filter.js`.
1828
2. Open your browser.

extension/eseaFilter.js

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
lastCountrySelected = "Country";
2+
var myInterval = setInterval(autoChecker, 500);
3+
console.log("ESEA Filter enabled")
4+
5+
function autoChecker() {
6+
teamList = document.getElementsByClassName('Tr');
7+
exists = document.getElementById('flag');
8+
if (teamList.length > 1 && (exists === null || exists === undefined) ) {
9+
doWork();
10+
document.getElementById("level").onchange = function () {
11+
console.log("Switched division");
12+
myInterval = setInterval(autoChecker, 500);
13+
};
14+
}
15+
}
16+
17+
function doWork() {
18+
class dropDownFilter {
19+
teamList = document.getElementsByClassName('Tr');
20+
totalFlags = [];
21+
flagImages = [];
22+
flagsCount = 0;
23+
flagBox = "";
24+
25+
constructor() { };
26+
create() {
27+
var regionBox = document.getElementById("region").parentElement.parentElement;
28+
this.flagBox = regionBox.cloneNode(true);
29+
this.flagBox.childNodes[0].childNodes[0].setAttribute("id", "flag");
30+
this.flagBox.style.top = "10px";
31+
this.flagBox.style.position = "relative";
32+
this.flagBox.childNodes[0].childNodes[0].innerHTML = "";
33+
34+
regionBox.parentElement.parentElement.parentElement.append(this.flagBox);
35+
36+
this.flagBox = document.getElementById("flag");
37+
}
38+
addDropDownFlag(flagName) {
39+
let newOption = document.createElement("option");
40+
newOption.text = flagName;
41+
this.flagBox.add(newOption);
42+
}
43+
addFlag(indexTeam) {
44+
this.flagOptions = this.flagBox.childNodes[0].childNodes[0];
45+
46+
let flagName = this.teamList[indexTeam].childNodes[1].childNodes[0].childNodes[0].title ?? this.teamList[indexTeam].childNodes[1].childNodes[0].childNodes[0].childNodes[0].textContent;
47+
for (let i = 0; i <= this.flagsCount; i++) {
48+
if (flagName == this.totalFlags[i]) return;
49+
}
50+
51+
this.totalFlags[this.flagsCount] = flagName;
52+
this.flagsCount++;
53+
}
54+
55+
fillDropDown() {
56+
for (let i = 0; i < this.totalFlags.length; i++) {
57+
this.addDropDownFlag(this.totalFlags[i]);
58+
if (this.totalFlags[i] == lastCountrySelected) this.flagBox.selectedIndex = i+1;
59+
}
60+
lastCountrySelected = this.selectedCountry();
61+
}
62+
63+
indexFlags() {
64+
this.addDropDownFlag("Country");
65+
66+
for (let i = 1; i < this.teamList.length; i++) {
67+
this.addFlag(i);
68+
}
69+
70+
this.totalFlags = this.totalFlags.sort();
71+
this.fillDropDown();
72+
}
73+
74+
selectedCountry() {
75+
return document.getElementById("flag").value;
76+
}
77+
} countryBox = new dropDownFilter;
78+
79+
class eseaHelper {
80+
teamList = document.getElementsByClassName('Tr');
81+
qeuedTeams = [];
82+
removedTeams = 0;
83+
84+
largeCutOff(teamsSize) {
85+
let newCuttOff = 0;
86+
switch (true) {
87+
case (teamsSize < 17):
88+
newCuttOff = 8;
89+
break;
90+
case (teamsSize >= 17 && teamsSize < 24):
91+
newCuttOff = 8;
92+
break;
93+
case (teamsSize >= 24 && teamsSize < 32):
94+
newCuttOff = 12;
95+
break;
96+
case (teamsSize >= 32 && teamsSize < 48):
97+
newCuttOff = 16;
98+
break;
99+
case (teamsSize >= 48 && teamsSize < 64):
100+
newCuttOff = 24;
101+
break;
102+
case (teamsSize >= 64 && teamsSize < 96):
103+
newCuttOff = 32;
104+
break;
105+
case (teamsSize >= 96 && teamsSize < 128):
106+
newCuttOff = 48;
107+
break;
108+
case (teamsSize >= 128 && teamsSize < 192):
109+
newCuttOff = 64;
110+
break;
111+
case (teamsSize >= 192 && teamsSize < 256):
112+
newCuttOff = 96;
113+
break;
114+
case (teamsSize >= 256 && teamsSize < 384):
115+
newCuttOff = 128;
116+
break;
117+
case (teamsSize >= 384 && teamsSize < 512):
118+
newCuttOff = 192;
119+
break;
120+
case (teamsSize >= 512 && teamsSize < 768):
121+
newCuttOff = 256;
122+
break;
123+
case (teamsSize >= 768 && teamsSize < 1024):
124+
newCuttOff = 384;
125+
break;
126+
default:
127+
newCuttOff = 4;
128+
break;
129+
}
130+
return newCuttOff;
131+
}
132+
133+
smallCutOff(teamsSize) {
134+
let newCuttOff = 0;
135+
switch (true) {
136+
case (teamsSize < 48):
137+
newCuttOff = 8;
138+
break;
139+
case (teamsSize >= 48 && teamsSize < 64):
140+
newCuttOff = 16;
141+
break;
142+
case (teamsSize >= 64 && teamsSize < 96):
143+
newCuttOff = 24;
144+
break;
145+
case (teamsSize >= 96 && teamsSize < 128):
146+
newCuttOff = 32;
147+
break;
148+
case (teamsSize >= 128 && teamsSize < 192):
149+
newCuttOff = 48;
150+
break;
151+
case (teamsSize >= 192 && teamsSize < 255):
152+
newCuttOff = 64;
153+
break;
154+
default:
155+
newCuttOff = 4;
156+
break;
157+
}
158+
return newCuttOff;
159+
}
160+
161+
getDivision() {
162+
return document.getElementById("level").value;
163+
}
164+
165+
getSeasonStage() {
166+
return seasonStage = document.getElementById("round").value;
167+
}
168+
169+
getCutOff() {
170+
let cutOffValue = 0;
171+
let teamsSize = this.teamList.length - 1;
172+
switch (esea.getDivision()) {
173+
case "open":
174+
cutOffValue = esea.largeCutOff(teamsSize);
175+
break;
176+
case "intermediate":
177+
cutOffValue = esea.largeCutOff(teamsSize);
178+
break;
179+
case "main":
180+
cutOffValue = esea.smallCutOff(teamsSize);
181+
break;
182+
case "advanced":
183+
cutOffValue = esea.smallCutOff(teamsSize);
184+
break;
185+
default:
186+
cutOffValue = -1;
187+
break;
188+
}
189+
return cutOffValue;
190+
}
191+
192+
printInfo() {
193+
console.log("Division: " + this.getDivision());
194+
let size = this.teamList.length - 1;
195+
console.log("Teams: " + size);
196+
console.log("Cutoff: " + this.getCutOff());
197+
}
198+
199+
filter() {
200+
let qeuedCount = 0;
201+
for (let i = 1; i < this.teamList.length; i++) {
202+
203+
let currentFlag = this.teamList[i].childNodes[1].childNodes[0].childNodes[0].title ?? this.teamList[i].childNodes[1].childNodes[0].childNodes[0].childNodes[0].textContent;
204+
if (countryBox.selectedCountry() == "Country") {
205+
currentFlag = countryBox.selectedCountry();
206+
}
207+
if (currentFlag != countryBox.selectedCountry()) {
208+
this.teamList[i].style.display = "none";
209+
} else {
210+
this.teamList[i].style.display = "";
211+
this.qeuedTeams[qeuedCount] = this.teamList[i];
212+
qeuedCount++;
213+
}
214+
}
215+
for (let i = 0; i < qeuedCount; i++) {
216+
let targetTeam = this.qeuedTeams[i];
217+
targetTeam.style.backgroundColor = 'rgb(51, 52, 51)';
218+
if (i % 2) targetTeam.style.backgroundColor = 'rgb(68, 68, 68)';
219+
220+
let teamRank = targetTeam.childNodes[0].textContent.slice(0, targetTeam.childNodes[0].textContent.length - 1);
221+
222+
if ( esea.getCutOff() < 0 || teamRank <= esea.getCutOff()) {
223+
targetTeam.childNodes[0].style.color = "green";
224+
} else {
225+
targetTeam.childNodes[0].style.color = "red";
226+
}
227+
}
228+
}
229+
} esea = new eseaHelper();
230+
231+
countryBox.create();
232+
countryBox.indexFlags();
233+
234+
document.getElementById("flag").onchange = function () {
235+
236+
lastCountrySelected = countryBox.selectedCountry();
237+
esea.filter();
238+
};
239+
240+
esea.printInfo();
241+
esea.filter();
242+
}

extension/manifest.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"manifest_version": 2,
3+
"name": "ESEA filter",
4+
"description": "A basic extension to ESEA seasons' ladderboards!",
5+
"version": "1.3",
6+
"author": "https://github.com/marqdevx",
7+
"permissions": [
8+
"https://play.esea.net/league/standings*"
9+
],
10+
"browser_specific_settings": {
11+
"gecko": {
12+
"id": "<id>",
13+
"strict_min_version": "78.0"
14+
}
15+
},
16+
"content_scripts": [
17+
{
18+
"matches": [
19+
20+
"*://*.play.esea.net/*"
21+
],
22+
"js": [
23+
"eseaFilter.js"
24+
]
25+
}
26+
]
27+
}

extension/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## ESEA Filter extension
2+
3+
This is a extension to filter [ESEA](https://play.esea.net) league divisions' [ladders](https://play.esea.net/league/standings).
4+
5+

0 commit comments

Comments
 (0)