diff --git a/images/female.png b/images/female.png new file mode 100644 index 0000000..3f84457 Binary files /dev/null and b/images/female.png differ diff --git a/images/gelding.png b/images/gelding.png new file mode 100644 index 0000000..55ee00d Binary files /dev/null and b/images/gelding.png differ diff --git a/images/male.png b/images/male.png new file mode 100644 index 0000000..58da5d8 Binary files /dev/null and b/images/male.png differ diff --git a/manifest.json b/manifest.json index 5293050..fa2134d 100644 --- a/manifest.json +++ b/manifest.json @@ -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" }, @@ -25,7 +38,8 @@ "*://*.howrse.com/*", "*://*.howrse.no/*", "*://*.howrse.co.uk/*", - "*://*.caballow.com/*" + "*://*.caballow.com/*", + "*://*.howrse.pl/*" ], "run_at": "document_end", "js": [ diff --git a/moreInfos.js b/moreInfos.js index 1ca1bdc..c3c42f1 100644 --- a/moreInfos.js +++ b/moreInfos.js @@ -8,6 +8,9 @@ class MoreInfos { constructor() { + this.parser = new DOMParser() + this.lang = translation.getLang(window.location.href) + this.regexpBlupHtml = /[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?<\/strong><\/td>/ this.regexpPGHtml = @@ -19,12 +22,12 @@ class MoreInfos { this.regexpPetHtmlSelf = /

.*<\/h3>/ + const genderLabel = `${translation.get(this.lang, 'sex', 'genderLabel')}`; + this.regexpSexHtml = `${genderLabel}<\/strong>\s*([^<]+)<\/td>`; + this.regexpFloat = /[+-]?(?=\d*[.eE])(?=\.?\d)\d*\.?\d*(?:[eE][+-]?\d+)?/ this.regexpValue = /\>(.*?)\ -1 this.sellsLocation = window.location.href.indexOf("marche/vente") > -1 @@ -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 = `
${name.innerHTML}
` + name.firstChild.appendChild(img) + } + if (!this.boxesLocation && this.locationAllowed) { const blupHtml = data.match(this.regexpBlupHtml) const PetHtml = diff --git a/translation.js b/translation.js index b42d75a..4da8777 100644 --- a/translation.js +++ b/translation.js @@ -27,6 +27,12 @@ class Translation { pet: 'Compagnon: ', pg: 'PG: ', skills: 'Compétences: ' + }, + sex: { + genderLabel: "Sexe :", + female: ' femelle', + male: ' mâle', + gelding: ' hongre' } }, en: { @@ -55,6 +61,12 @@ class Translation { pet: 'Pet: ', pg: 'GP: ', skills: 'Skills: ' + }, + sex: { + genderLabel: "Gender:", + female: ' female', + male: ' male', + gelding: ' gelding' } }, no: { @@ -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', @@ -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: { @@ -139,6 +163,12 @@ class Translation { pet: 'Mascota: ', pg: 'PG: ', skills: 'Habilidades: ' + }, + sex: { + genderLabel: "Sexo:", + female: ' hembra', + male: ' macho', + gelding: ' castrado' } } }