limmlingg / I-M-a-converter

A chrome extension that automatically converts from Imperial units to Metric and vice versa
0 stars 0 forks source link

HTML replace duplicates and has weird titles #1

Open limmlingg opened 5 years ago

limmlingg commented 5 years ago

Noticeable on sites like https://www.metric-conversions.org/temperature/fahrenheit-to-celsius.htm. Can also be observed in the feet and inches test page.

When looking at the modified HTML, you can see that the title takes on a weird value: title="<strange number carried over from somewhere> <f2ctag style="..........

When I console.log the title in the method, it gives me what I expect i.e. 212°F = 100°C. Maybe something is wrong with my innerHTML.replace()? We might need to explore using a different method to do conversion.js: setTitle().

limmlingg commented 5 years ago

As an example, on the site:

<td>-459.67°F</td>

becomes

<td><f2ctag style="border-bottom: 2px solid #fea" title="-459.6<f2ctag style=" border-bottom:="" 2px="" solid="" #fea"=""> 7°F</f2ctag> = <f2ctag style="border-bottom: 2px solid #fea" title="-459.67°F = -273.15°C = 0.00K"> -273.15°C</f2ctag> = 0.00K"&gt; -459.6<f2ctag style="border-bottom: 2px solid #fea" title="7.00°F = <f2ctag style=" border-bottom:="" 2px="" solid="" #fea"=""> -1<f2ctag style="border-bottom: 2px solid #fea" title="39.00°F = 3.89°C = 277.04K"> 3.89°C</f2ctag></f2ctag> = 259.26K"&gt; 7°F</td>

This could be due to the extension detecting 7°F elsewhere on the site and replacing it again. However, the 7°F further down the site doesn't seem to have been detected/replaced as it has an <abbr> tag between the number and the unit.