Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not convert 'F' unit #8

Open
haarp opened this issue Jul 14, 2020 · 5 comments
Open

Does not convert 'F' unit #8

haarp opened this issue Jul 14, 2020 · 5 comments

Comments

@haarp
Copy link

haarp commented Jul 14, 2020

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!

@getsnoopy
Copy link

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

@MaZZly
Copy link

MaZZly commented Jul 3, 2022

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

Similar to #14 usually people on reddit, and some recipe sites, only write out 100F instead of the correct 100°F

@getsnoopy
Copy link

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.

@MaZZly
Copy link

MaZZly commented Jul 11, 2022

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();
})();

@mirh
Copy link

mirh commented Mar 5, 2023

askielboe@e697951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants