Copied base functionality from percentage-calculator-firefox