Everything-Metric icon indicating copy to clipboard operation
Everything-Metric copied to clipboard

Does not convert 'F' unit

Open haarp opened this issue 4 years ago • 5 comments

Hello and thanks for this extension!

Many Murkans fail to understand that their temperature unit is "degrees Fahrenheit" and just say things liek 100F instead of 100°F. This extension does notice or convert these. could that be fixed?

Thanks!

haarp avatar Jul 14 '20 08:07 haarp

100F, ignoring the lack of a space between the quantity and the unit symbol, means "100 Farads", a unit of electrical capacitance.

getsnoopy avatar Aug 26 '20 00:08 getsnoopy

@getsnoopy could this be added as an option (pretty please), although it not being "scientifically correct".

Similar to https://github.com/m1l/Everything-Metric/issues/14 usually people on reddit, and some recipe sites, only write out 100F instead of the correct 100°F

MaZZly avatar Jul 03 '22 10:07 MaZZly

Well the correct formatting would be 100 °F (the space is required), but yes, as an extension, it should be as flexible/forgiving as possible in recognizing units. But that's for the maintainer to decide.

getsnoopy avatar Jul 11 '22 05:07 getsnoopy

Yep, I think it would be best as an optional setting for those who are not as strict with their units :)

For now I just wrote my own lazy TamperMonkey script that does the same:

// ==UserScript==
// @name         F->C convert
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Crude conversion of **F into Celsius equivalent
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    const regex = /(\d+)F/gi;
    const fahrenheitToCelsius = fahrenheit => (fahrenheit - 32) * 5/9;

    var convertUnits = function () {
        let paragraphs = document.querySelectorAll("p");
        function farenheitReplace(match, p1, p2) {
            return p1 + 'F【'+ Math.round(fahrenheitToCelsius(p1)*10)/10 + 'C】';
        }
        for (let i = 0; i < paragraphs.length; i++) {
            paragraphs[i].innerHTML = paragraphs[i].innerHTML.replace(regex, farenheitReplace);
        }
    }
    convertUnits();
})();

MaZZly avatar Jul 11 '22 07:07 MaZZly

https://github.com/askielboe/Everything-Metric/commit/e6979517faa959e7c903aff30f538544e2892745

mirh avatar Mar 05 '23 22:03 mirh