-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from Gwenillia/vx.y.z
v2.0.0-rc.1
- Loading branch information
Showing
12 changed files
with
529 additions
and
465 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"appName": { | ||
"message": "Better Howrse", | ||
"description": "Navnet på utvidelsen." | ||
}, | ||
"appDesc": { | ||
"message": "Denne utvidelsen viser mer informasjon i spillet om hester og konkurranser for å få deg til å føle deg mer komfortabel når du spiller.", | ||
"description": "Beskrivelse av utvidelsen.Beskrivelse av utvidelsen." | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2022. Gwen Tripet-Costet | ||
* This file is part of Better Equideow (Better Howrse). | ||
* Better Equideow (Better Howrse) is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. | ||
* Better Equideow (Better Howrse) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
class FoodSelect { | ||
constructor() { | ||
this.feedingBtn = this.setHTMLElement("#boutonNourrir") | ||
this.haySlider = this.setHTMLElement("#haySlider") || null // entire bloc containing ol, script, li, span | ||
this.haySelectors = this.haySlider?.getElementsByTagName("span") // all span selectors from 0 to 20 | ||
this.oatsSlider = this.setHTMLElement("#oatsSlider") || null | ||
this.oatsSelectors = this.oatsSlider?.getElementsByTagName("span") | ||
} | ||
|
||
setHTMLElement(element) { | ||
return document.querySelector(element) | ||
}; | ||
|
||
getFoodIndex(foodNode) { | ||
const foodValue = foodNode.innerHTML | ||
const foodIndex = parseInt(foodValue) | ||
return foodIndex | ||
} | ||
|
||
|
||
async run() { | ||
// will get the value eg: XX/20 for hay and X/16 for oats. | ||
const fourrageNode = document.getElementsByClassName( | ||
"section-fourrage section-fourrage-target" | ||
) | ||
const avoineNode = document.getElementsByClassName( | ||
"section-avoine section-avoine-target" | ||
) | ||
|
||
if (fourrageNode.length > 0) { | ||
const fourrageIndex = this.getFoodIndex(fourrageNode[0]) | ||
this.haySelectors[fourrageIndex].click() | ||
} | ||
|
||
if (avoineNode.length > 0) { | ||
const avoineIndex = this.getFoodIndex(avoineNode[0]) | ||
this.oatsSelectors[avoineIndex].click() | ||
} | ||
} | ||
} | ||
|
||
if (window.location.href.indexOf("elevage/chevaux/cheval?") > -1) { | ||
const foodSelect = new FoodSelect() | ||
if (foodSelect.feedingBtn !== null) | ||
foodSelect.feedingBtn.addEventListener("click", () => { | ||
foodSelect.run() | ||
}) | ||
|
||
/** | ||
* @description generate a new FoodSelect() because after #loading style change, | ||
* it seems like the different this.elements from foodSelect are erased .. | ||
* @todo fix it... | ||
*/ | ||
const startObserver = () => { | ||
observer.start().then(() => { | ||
let newFoodSelect = new FoodSelect() | ||
newFoodSelect.run() | ||
startObserver() | ||
}) | ||
} | ||
|
||
startObserver() | ||
} |
Oops, something went wrong.