From cc6e9c1a5f440a07ed86be6827d78345dcb3537c Mon Sep 17 00:00:00 2001 From: Gwenillia <55385809+Gwenillia@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:50:28 +0200 Subject: [PATCH] polish + gender icon (#82) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- images/female.png | Bin 0 -> 871 bytes images/gelding.png | Bin 0 -> 707 bytes images/male.png | Bin 0 -> 903 bytes manifest.json | 16 ++++++++++++- moreInfos.js | 29 ++++++++++++++++++++--- translation.js | 56 ++++++++++++++++++++++++++++++++++----------- 6 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 images/female.png create mode 100644 images/gelding.png create mode 100644 images/male.png diff --git a/images/female.png b/images/female.png new file mode 100644 index 0000000000000000000000000000000000000000..3f8445780c4a79c96accb030a1dddf0531bb59a0 GIT binary patch literal 871 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQa%*9TgAsieWw;%dHU|?Wu4)6(a z{SOBB|0i7k6MN=<-2Tf^yDvoE{vQwIUYK2Qv#TB`^?LK>7i*SZtW5(-y`8-Nz@oT^ zz5V-Z6D~ZDgJ}7*D6BobjKl^#h;ho!~Ue8#&V`cR9gzB%m z&+I=Dy=!08o*mKqrzUNj9<{0`Y+Gsk*42^grbd2WcVx}X@HNvTUX@K-zFetN{i@T&LCOP4oCyvXWX+8DN^GJI81^iBVwPg6F3oV4kE z`^q<^b6=LuTv8J8B)ai=M9V|h%8Q;kFSDk-%$)E%v43G!_~U@)hd$M}eM^=F#LNv0 z+wGY0wru{hyjf4Pra#Y`@+@u2bl@schk1wo^|;HtK#d{`B%)d&sr8= zGtJv=mvq~>@RniWUaRbL#`&j>3(gp)Ewhc>VwN<|CT4?q!XBfHeTLcFjnek(XYMvg z->;Xo#5{7lLGn?pwC(z7iwvT+YNf8$N?fm;v`jT}nM$msYjQd;b{b29{DK(-!9WQJ zjDf%f1VW)84Fbxcprd0Z1grvq-Mh~~z+E_a2M3TyCW<_!l+6Ql3}=ByWHAE+w-5+3 zUb-L1;Fyx1l&avCS(I9yUzA;};2dnKXSiD4<26v_5loY=uuA1HF&+e#(8Euw3|&&f9z2h8TY`PZs zlb@bp=e~8vG@86-9$mRIbn8Kx6HPg@svK3#er4%os8vkMO1N=2Vd8p@WG04Nca`dj T`uXnx{lnnt>gTe~DWM4f#T&i| literal 0 HcmV?d00001 diff --git a/images/gelding.png b/images/gelding.png new file mode 100644 index 0000000000000000000000000000000000000000..55ee00d3a054bc69fed0743adb165b8d347ec6dd GIT binary patch literal 707 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQa%*9TgAsieWw;%dHU|?X>4DbnY z{SN}F|NqOqdH3%Be}@0R<^KP%0&+p@AGSwMU){7hZRyI4|NnJi8+}Sk!d0O4| z-0C?ykAB&-|J%HEAE(a9Tes)i(k-86t@*lXLp)G%byIzLeSJxFgJ;so<{9sS3Z~8| z49{2^nK3iH@l{yn>UrzGw9ok*l04ld@w$J)ivGo4>!y4v>iXcB{=hc&sejxIyXb4q z(fjPek4BZfi70v%lK&Iq*=u@-MduD+* zi~=7T1isMse`*l$RNw!hUBD6x{~bnt*K|Fvnt83z_dIIqxmL^NgofiD727>htvjND zVVGPJ#l68|#zKjVGfcu$K9@dYHx~KhYmv~@#OJsvq0P02 zFGjVwZpB`P2|k;b4XE8g9#|RX{f~c)I$ztaD0e0sz2CTl4?` literal 0 HcmV?d00001 diff --git a/images/male.png b/images/male.png new file mode 100644 index 0000000000000000000000000000000000000000..58da5d83b9432d53f388bdd63a7a6fec74e3bd0d GIT binary patch literal 903 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQa%*9TgAsieWw;%dHU|?XJ8sHP+ z`X2;7{{L_M|3Aa4H}Bp)G1#>G(5~$7F zewn-KV)v{)m3@y(>ihqFv_60B%k9g4yS7Jd+Z?;===&}E-yGZ{;D}GcozAHXZm1G`w@p^SqWTq1k&DZu~rd{f7k$GkPZ$b@rCzR7_5-Shs%fw~gx} z)~rrkyeO@(svRU)GA}ZF?V8%g3s0Xgpia-RESzVS(a?v?h!J^86) z;&bPO=XSBLtz+I;N4+qQd}$K)$|n4RRp=R)(D}x}PYnW|S_baZ_kW=0|IE<;w!Y6z zL+|ruzPogN?&|v7*7AC6=yk}{dy|&uZ9UI3I_?(?-PanrZPa!-sNuL<(_xF6-5v#- z3wx(codt}q_L3mKUt~C6u3Q3oH(Vmu(Q+6&D~XP#R9HRyW3M!ug_Yj z`Sh!g{)#K@#jPP*MQ%u}d6eC>I-yBtnqZ;k#>TipUAJ$!%K{Ahmplu&|6x*3mav|o zb!EqbvYh6P7Rwh@2KFg2GaI|~oLzozn)HzZ&20_QN-`lD>}eS(zYGtvxH=UrJ;?Lb zq+V`@!tUsOj58j_ykZDHxgc`Fsxt=;WJp|I(e{C3b++rG?ZFO3t9jWceg7eI`t_+< upVqJj*qqf_x_Y_t$s-MXGYnlWFfcglsoJR6U)lil7lWs(pUXO@geCy@<<92- literal 0 HcmV?d00001 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' } } }