Skip to content

Commit

Permalink
polish + gender icon (#82)
Browse files Browse the repository at this point in the history
* Added spanish translation

* delete typo

* Added messages in spanish

* Add caballow to content_scripts

* Fix name of showJumping in es

* Feat: More info about the gender of the horse (only in spanish)

* wip: added little translation of the genders

* fix: the gender img now shows only in moreinfo view

* feat: add lenguge support for the gender feature

* Clean and polish

I did some cleaning for the img display and for the regexp to match
special characters. Also added some polih strings

---------

Co-authored-by: Andrea Méndez Sanz <[email protected]>
  • Loading branch information
Gwenillia and AndreaMendez09 authored Apr 18, 2024
1 parent 0c99878 commit cc6e9c1
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 17 deletions.
Binary file added images/female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/gelding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
"48": "/images/icon-48x48.png",
"128": "/images/icon-128x128.png"
},
"web_accessible_resources": [
{
"resources": ["images/male.png", "images/female.png", "images/gelding.png"],
"matches": [
"*://*.equideow.com/*",
"*://*.howrse.com/*",
"*://*.howrse.no/*",
"*://*.howrse.co.uk/*",
"*://*.caballow.com/*",
"*://*.howrse.pl/*"
]
}
],
"action": {
"default_popup": "popup.html"
},
Expand All @@ -25,7 +38,8 @@
"*://*.howrse.com/*",
"*://*.howrse.no/*",
"*://*.howrse.co.uk/*",
"*://*.caballow.com/*"
"*://*.caballow.com/*",
"*://*.howrse.pl/*"
],
"run_at": "document_end",
"js": [
Expand Down
29 changes: 26 additions & 3 deletions moreInfos.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class MoreInfos {
constructor() {
this.parser = new DOMParser()
this.lang = translation.getLang(window.location.href)

this.regexpBlupHtml =
/<td class="last align-right" width="15%" dir="ltr"><strong class="nowrap">[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?<\/strong><\/td>/
this.regexpPGHtml =
Expand All @@ -19,12 +22,12 @@ class MoreInfos {
this.regexpPetHtmlSelf =
/<h3 id="compagnon-head-title" class="align-center module-style-6-title module-title">.*<\/h3>/

const genderLabel = `${translation.get(this.lang, 'sex', 'genderLabel')}`;
this.regexpSexHtml = `<td class="first"><strong>${genderLabel}<\/strong>\s*([^<]+)<\/td>`;

this.regexpFloat = /[+-]?(?=\d*[.eE])(?=\.?\d)\d*\.?\d*(?:[eE][+-]?\d+)?/
this.regexpValue = /\>(.*?)\</

this.parser = new DOMParser()
this.lang = translation.getLang(window.location.href)

this.elevageLocation =
window.location.href.indexOf("elevage/chevaux/?elevage") > -1
this.sellsLocation = window.location.href.indexOf("marche/vente") > -1
Expand Down Expand Up @@ -84,6 +87,26 @@ class MoreInfos {
infoDiv.style.margin = ".25em 0"
infoDiv.style.color = "#993322"


if (this.elevageLocation) {
const sexHTML = data.match(this.regexpSexHtml);

const img = document.createElement("img")

console.log(sexHTML[1])
console.log(`translation ${translation.get(this.lang, 'sex', 'female')}`)
if (sexHTML[1] === `${translation.get(this.lang, 'sex', 'female')}`) {
img.src = chrome.runtime.getURL("images/female.png")
} else if (sexHTML[1] === `${translation.get(this.lang, 'sex', 'male')}`) {
img.src = chrome.runtime.getURL("images/male.png")
} else {
img.src = chrome.runtime.getURL("images/gelding.png")
}

name.innerHTML = `<div style="display: flex; justify-content: space-between; height: 1rem;">${name.innerHTML}</div>`
name.firstChild.appendChild(img)
}

if (!this.boxesLocation && this.locationAllowed) {
const blupHtml = data.match(this.regexpBlupHtml)
const PetHtml =
Expand Down
56 changes: 43 additions & 13 deletions translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class Translation {
pet: 'Compagnon: ',
pg: 'PG: ',
skills: 'Compétences: '
},
sex: {
genderLabel: "Sexe :",
female: ' femelle',
male: ' mâle',
gelding: ' hongre'
}
},
en: {
Expand Down Expand Up @@ -55,6 +61,12 @@ class Translation {
pet: 'Pet: ',
pg: 'GP: ',
skills: 'Skills: '
},
sex: {
genderLabel: "Gender:",
female: ' female',
male: ' male',
gelding: ' gelding'
}
},
no: {
Expand Down Expand Up @@ -83,23 +95,29 @@ class Translation {
pet: 'Følgesvenner: ',
pg: 'GP: ',
skills: 'Ferdigheter: '
},
sex: {
genderLabel: "Kjønn:",
female: ' hunkjønn',
male: ' hannkjønn',
gelding: ' vallak'
}
},
pl: {
stat: {
stamina: 'stamina',
speed: 'speed',
dressage: 'dressage',
gallop: 'gallop',
trot: 'trot',
jumping: 'jumping'
stamina: 'wytrzymałość',
speed: 'prędkość',
dressage: 'ujeżdżenie',
gallop: 'galop',
trot: 'kłus',
jumping: 'skoki'
},
competition: {
trot: 'Trot',
gallop: 'Gallop',
dressage: 'Dressage',
crossCountry: 'Cross-country',
showJumping: 'Show jumping',
trot: 'Kłus',
gallop: 'Galop',
dressage: 'Ujeżdżenie',
crossCountry: 'Biegi przełajowe',
showJumping: 'Skoki przez przeszkody',
barrelRacing: 'Barrel racing',
cutting: 'Cutting',
trailClass: 'Trail class',
Expand All @@ -108,9 +126,15 @@ class Translation {
disclaimer: 'The higher the coefficient, the greater the chance of winning'
},
other: {
pet: 'Pet: ',
pet: 'Towarzysz: ',
pg: 'GP: ',
skills: 'Skills: '
skills: 'Umiejętności: '
},
sex: {
genderLabel: "Płeć:",
female: ' klacz',
male: ' ogier',
gelding: ' wałach'
}
},
es: {
Expand Down Expand Up @@ -139,6 +163,12 @@ class Translation {
pet: 'Mascota: ',
pg: 'PG: ',
skills: 'Habilidades: '
},
sex: {
genderLabel: "Sexo:",
female: ' hembra',
male: ' macho',
gelding: ' castrado'
}
}
}
Expand Down

0 comments on commit cc6e9c1

Please sign in to comment.