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

Commit

Permalink
Auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
marqdevx committed Jan 21, 2023
1 parent 2c59c84 commit 48432a8
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 52 deletions.
80 changes: 47 additions & 33 deletions esea-league-filter-bookmark.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
javascript: (() => {
function doWork() {
var myInterval = setInterval(autoChecker, 500);

function autoChecker() {
console.log("Checking");
teamList = document.getElementsByClassName('Tr');
exists = document.getElementById('flag');
if (teamList.length > 1 && !exists) {
doWork();
clearInterval(myInterval);
document.getElementById("level").onchange = function () {
console.log("Switched division");
myInterval = setInterval(autoChecker, 500);
};
}
}

function doWork() {
class dropDownFilter {
teamList = document.getElementsByClassName('Tr');
totalFlags = [];
flagImages = [];
flagsCount = 0;
flagBox = "";

constructor() { };
create() {
var regionBox = document.getElementById("region").parentElement.parentElement;
this.flagBox = regionBox.cloneNode(true);
this.flagBox.childNodes[0].childNodes[0].setAttribute("id", "flag");
this.flagBox.childNodes[0].style.top = "10px";
this.flagBox.childNodes[0].childNodes[0].innerHTML = "";
regionBox.parentElement.parentElement.parentElement.append(this.flagBox);
this.flagBox = document.getElementById("flag");
var regionBox = document.getElementById("region").parentElement.parentElement;
this.flagBox = regionBox.cloneNode(true);
this.flagBox.childNodes[0].childNodes[0].setAttribute("id", "flag");
this.flagBox.childNodes[0].style.top = "10px";
this.flagBox.childNodes[0].childNodes[0].innerHTML = "";

regionBox.parentElement.parentElement.parentElement.append(this.flagBox);

this.flagBox = document.getElementById("flag");
}
addDropDownFlag(flagName) {
let newOption = document.createElement("option");
Expand All @@ -28,43 +42,43 @@ javascript: (() => {
}
addFlag(indexTeam) {
this.flagOptions = this.flagBox.childNodes[0].childNodes[0];

let flagName = this.teamList[indexTeam].childNodes[1].childNodes[0].childNodes[0].title ?? this.teamList[indexTeam].childNodes[1].childNodes[0].childNodes[0].childNodes[0].textContent;
for (let i = 0; i <= this.flagsCount; i++) {
if (flagName == this.totalFlags[i]) return;
}

this.totalFlags[this.flagsCount] = flagName;
this.flagsCount++;
}

fillDropDown() {
for (let i = 0; i < this.totalFlags.length; i++) {
this.addDropDownFlag(this.totalFlags[i]);
}
}

indexFlags() {
this.addDropDownFlag("Country");

for (let i = 1; i < this.teamList.length; i++) {
this.addFlag(i);
}

this.totalFlags = this.totalFlags.sort();
this.fillDropDown();
}

selectedCountry() {
return document.getElementById("flag").value;
}
} countryBox = new dropDownFilter;

class eseaHelper {
teamList = document.getElementsByClassName('Tr');
qeuedTeams = [];
removedTeams = 0;

largeCutOff(teamsSize) {
let newCuttOff = 0;
switch (true) {
Expand Down Expand Up @@ -113,7 +127,7 @@ javascript: (() => {
}
return newCuttOff;
}

smallCutOff(teamsSize) {
let newCuttOff = 0;
switch (true) {
Expand Down Expand Up @@ -141,15 +155,15 @@ javascript: (() => {
}
return newCuttOff;
}

getDivision() {
return document.getElementById("level").value;
}

getSeasonStage() {
return seasonStage = document.getElementById("round").value;
}

getCutOff() {
let cutOffValue = 0;
let teamsSize = this.teamList.length - 1;
Expand All @@ -169,18 +183,18 @@ javascript: (() => {
}
return cutOffValue;
}
printInfo(){

printInfo() {
console.log("Division: " + this.getDivision());
let size = this.teamList.length - 1;
console.log("Teams: " + size);
console.log("Cutoff: " + this.getCutOff());
}

filter() {
let qeuedCount = 0;
for (let i = 1; i < this.teamList.length; i++) {

let currentFlag = this.teamList[i].childNodes[1].childNodes[0].childNodes[0].title ?? this.teamList[i].childNodes[1].childNodes[0].childNodes[0].childNodes[0].textContent;
if (countryBox.selectedCountry() == "Country") {
currentFlag = countryBox.selectedCountry();
Expand All @@ -197,9 +211,9 @@ javascript: (() => {
let targetTeam = this.qeuedTeams[i];
targetTeam.style.backgroundColor = 'rgb(51, 52, 51)';
if (i % 2) targetTeam.style.backgroundColor = 'rgb(68, 68, 68)';

let teamRank = targetTeam.childNodes[0].textContent.slice(0, targetTeam.childNodes[0].textContent.length - 1);

if (teamRank <= esea.getCutOff()) {
targetTeam.childNodes[0].style.color = "green";
} else {
Expand All @@ -208,15 +222,15 @@ javascript: (() => {
}
}
} esea = new eseaHelper();

countryBox.create();
countryBox.indexFlags();

document.getElementById("flag").onchange = function () {
esea.filter();
};

esea.printInfo();
esea.filter();
}

doWork();
})();
52 changes: 33 additions & 19 deletions esea-league-filter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
function doWork() {

var myInterval = setInterval(autoChecker, 500);

function autoChecker() {
console.log("Checking");
teamList = document.getElementsByClassName('Tr');
exists = document.getElementById('flag');
if (teamList.length > 1 && !exists) {
doWork();
clearInterval(myInterval);
document.getElementById("level").onchange = function () {
console.log("Switched division");
myInterval = setInterval(autoChecker, 500);
};
}
}

function doWork() {
class dropDownFilter {
teamList = document.getElementsByClassName('Tr');
totalFlags = [];
Expand All @@ -10,15 +24,15 @@ function doWork() {

constructor() { };
create() {
var regionBox = document.getElementById("region").parentElement.parentElement;
this.flagBox = regionBox.cloneNode(true);
this.flagBox.childNodes[0].childNodes[0].setAttribute("id", "flag");
this.flagBox.childNodes[0].style.top = "10px";
this.flagBox.childNodes[0].childNodes[0].innerHTML = "";

regionBox.parentElement.parentElement.parentElement.append(this.flagBox);
this.flagBox = document.getElementById("flag");
var regionBox = document.getElementById("region").parentElement.parentElement;
this.flagBox = regionBox.cloneNode(true);
this.flagBox.childNodes[0].childNodes[0].setAttribute("id", "flag");
this.flagBox.childNodes[0].style.top = "10px";
this.flagBox.childNodes[0].childNodes[0].innerHTML = "";

regionBox.parentElement.parentElement.parentElement.append(this.flagBox);

this.flagBox = document.getElementById("flag");
}
addDropDownFlag(flagName) {
let newOption = document.createElement("option");
Expand Down Expand Up @@ -169,7 +183,7 @@ function doWork() {
return cutOffValue;
}

printInfo(){
printInfo() {
console.log("Division: " + this.getDivision());
let size = this.teamList.length - 1;
console.log("Teams: " + size);
Expand All @@ -179,7 +193,7 @@ function doWork() {
filter() {
let qeuedCount = 0;
for (let i = 1; i < this.teamList.length; i++) {

let currentFlag = this.teamList[i].childNodes[1].childNodes[0].childNodes[0].title ?? this.teamList[i].childNodes[1].childNodes[0].childNodes[0].childNodes[0].textContent;
if (countryBox.selectedCountry() == "Country") {
currentFlag = countryBox.selectedCountry();
Expand All @@ -198,7 +212,7 @@ function doWork() {
if (i % 2) targetTeam.style.backgroundColor = 'rgb(68, 68, 68)';

let teamRank = targetTeam.childNodes[0].textContent.slice(0, targetTeam.childNodes[0].textContent.length - 1);

if (teamRank <= esea.getCutOff()) {
targetTeam.childNodes[0].style.color = "green";
} else {
Expand All @@ -210,11 +224,11 @@ function doWork() {

countryBox.create();
countryBox.indexFlags();
/*document.getElementById("flag").onchange = function () {

document.getElementById("flag").onchange = function () {
esea.filter();
};*/
};

esea.printInfo();
esea.filter();
}

doWork();
}

0 comments on commit 48432a8

Please sign in to comment.