Skip to content

Commit

Permalink
Merge pull request #36 from Gwenillia/fix/PetInfos
Browse files Browse the repository at this point in the history
Fix/pet infos
  • Loading branch information
Gwenillia authored Jan 6, 2023
2 parents d4c7e4b + 5d74902 commit 20c665d
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions moreInfos.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ const regexpPGHtml =
/<strong>Total.+[+-]?(?=\d*[.eE])(?=\.?\d)\d*\.?\d*(?:[eE][+-]?\d+)?<\/strong>/;
const regexpSkillsHtml =
/<span id="competencesValeur">[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?<\/span>/;
const regexpPetHtml =
const regexpPetHtmlOthers =
/<h3 class="align-center module-style-6-title module-title">.*<\/h3>/;
const regexpPetHtmlSelf =
/<h3 id="compagnon-head-title" class="align-center module-style-6-title module-title">.*<\/h3>/;

const regexpFloat = /[+-]?(?=\d*[.eE])(?=\.?\d)\d*\.?\d*(?:[eE][+-]?\d+)?/;
const regexpValue = /\>(.*?)\</;
Expand Down Expand Up @@ -51,9 +53,11 @@ const elevageLocation =
window.location.href.indexOf("elevage/chevaux/?elevage") > -1;
const sellsLocation = window.location.href.indexOf("marche/vente") > -1;
const boxesLocation = window.location.href.indexOf("centre/box") > -1;
const communauteLocation =
window.location.href.indexOf("communaute/?type=tab-chevaux") > -1;

let locationAllowed;
if (elevageLocation || sellsLocation || boxesLocation) {
if (elevageLocation || sellsLocation || boxesLocation || communauteLocation) {
locationAllowed = true;
}

Expand All @@ -72,9 +76,14 @@ function moreInfos() {
infoDiv.style.margin = ".25em 0";
infoDiv.style.color = "#993322";

if (elevageLocation || sellsLocation) {
console.log(communauteLocation);
// if (elevageLocation || sellsLocation) {
if (!boxesLocation && locationAllowed) {
console.log("location not box");
const blupHtml = data.match(regexpBlupHtml);
const PetHtml = data.match(regexpPetHtml);
const PetHtml =
data.match(regexpPetHtmlOthers) || data.match(regexpPetHtmlSelf);
console.log(PetHtml);
if (blupHtml) {
const blupFloat = blupHtml[0].match(regexpFloat);
parseHTML(
Expand All @@ -86,6 +95,7 @@ function moreInfos() {
);
}
if (PetHtml) {
console.log(PetHtml);
const PetName = PetHtml[0].match(regexpValue);
console.log(PetName);
parseHTML(
Expand Down Expand Up @@ -154,6 +164,15 @@ Array.from(breedingsBtn).forEach((breedingBtn) => {
});
});

setTimeout(() => {
const searchBtnCommunaute = document.querySelector("#searchHorseButton");
searchBtnCommunaute.addEventListener("click", () => {
setTimeout(() => {
moreInfos();
}, 250);
});
}, 250);

setTimeout(() => {
moreInfos();
}, 250);

0 comments on commit 20c665d

Please sign in to comment.