Skip to content

Commit

Permalink
Merge pull request #63 from Gwenillia/v2.1.2-small-fix
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
Gwenillia authored Feb 2, 2023
2 parents 5cce933 + edcdfba commit 4f3f00a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Il s'agit la des nouvelles et anciennes version de l'extension trouvable en stor

---
## Better Howrse
Small chrome extension for Howrse that allow you to get more informations about your horses and competition difficulties. (highest coeff is highest winning rate)
Small browser extension for Howrse that allow you to get more informations about your horses and competition difficulties. (highest coeff is highest winning rate)

Pet names displayed in the same way as other informations. Also will include theses infos from the research view

Expand All @@ -22,7 +22,7 @@ Switch to the previous or next horse using left and right arrow keys on your key
Here are available all recents and pasts updates of the browser extension that you can find on the stores.

---
[![Last Version](https://img.shields.io/badge/last%20version-v2.1.1-informational)](#)
[![Last Version](https://img.shields.io/badge/last%20version-v2.1.2-informational)](#)
[![DeepScan grade](https://deepscan.io/api/teams/17688/projects/21040/branches/592899/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=17688&pid=21040&bid=592899)

[![Chrome Web Store](https://img.shields.io/chrome-web-store/v/gkopbgamdhaolbjalfcbmbjkjcmgffjp)](https://chrome.google.com/webstore/detail/better-equideow/gkopbgamdhaolbjalfcbmbjkjcmgffjp)
Expand Down
41 changes: 17 additions & 24 deletions foodSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,44 @@

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.feedingBtn = document.getElementById("boutonNourrir")
this.haySlider = document.getElementById("haySlider") || null
this.haySelectors = this.haySlider?.getElementsByTagName("span")
this.oatsSlider = document.getElementById("oatsSlider") || null
this.oatsSelectors = this.oatsSlider?.getElementsByTagName("span")
}

setHTMLElement(element) {
return document.querySelector(element)
};

getFoodIndex(foodNode) {
const foodValue = foodNode.innerHTML
const foodValue = foodNode.textContent
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"
)
const fourrageNode = document.getElementsByClassName("section-fourrage section-fourrage-target")[0]
const avoineNode = document.getElementsByClassName("section-avoine section-avoine-target")[0]

if (fourrageNode.length > 0) {
const fourrageIndex = this.getFoodIndex(fourrageNode[0])
if (fourrageNode) {
const fourrageIndex = this.getFoodIndex(fourrageNode)
this.haySelectors[fourrageIndex].click()
}

if (avoineNode.length > 0) {
const avoineIndex = this.getFoodIndex(avoineNode[0])
if (avoineNode) {
const avoineIndex = this.getFoodIndex(avoineNode)
this.oatsSelectors[avoineIndex].click()
}
}
}

if (window.location.href.indexOf("elevage/chevaux/cheval?") > -1) {
const foodSelect = new FoodSelect()
if (foodSelect.feedingBtn !== null)
const horseFeedingPageRegex = /\/elevage\/chevaux\/cheval\?/

if (window.location.href.match(horseFeedingPageRegex)) {
let foodSelect = new FoodSelect()
if (foodSelect.feedingBtn !== null) {
foodSelect.feedingBtn.addEventListener("click", () => {
foodSelect.run()
})
}

/**
* @description generate a new FoodSelect() because after #loading style change,
Expand Down
4 changes: 3 additions & 1 deletion loadingDisplayObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class LoadingDisplayObserver {
this.targetNode = document.querySelector('#loading');
this.config = { attributes: true, attributeFilter: ['style'] };
}

start() {
return new Promise((resolve) => {
this.observer = new MutationObserver((mutationsList) => {
Expand All @@ -19,7 +20,8 @@ class LoadingDisplayObserver {
let element = mutation.target;
let display = window.getComputedStyle(element, null).getPropertyValue("display");
if (display === "none") {
resolve();
resolve();
this.stop();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"default_locale": "fr",
"version": "2.1.1",
"version": "2.1.2",
"manifest_version": 3,
"author": "TC-Dev",
"icons": {
Expand Down

0 comments on commit 4f3f00a

Please sign in to comment.