metric-yummly

Automatically switches from imperial to metric measurements

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            metric-yummly
// @author          Davor Babic
// @namespace       http://www.github.com/davorb/metric-yummly
// @description     Automatically switches from imperial to metric measurements
// @license         Creative Commons Attribution License
// @version         0.3
// @include         http://www.yummly.com/*
// @released        2014-06-06
// @updated         2006-04-06
// @compatible      Greasemonkey
// @grant           none
// ==/UserScript==

/*
 * This file is a Greasemonkey user script. To install it, you need
 * the Firefox plugin "Greasemonkey" (URL: http://greasemonkey.mozdev.org/)
 * After you installed the extension, restart Firefox and revisit
 * this script. Now you will see a new menu item "Install User Script"
 * in your tools menu.
 *
 * To uninstall this script, go to your "Tools" menu and select
 * "Manage User Scripts", then select this script from the list
 * and click uninstall :-)
 *
 * Creative Commons Attribution License (--> or Public Domain)
 * http://creativecommons.org/licenses/by/2.5/
*/

(function(){
  function contains(s) {
    return location.toString().search(s) !== -1;
  }

  function searchContains(s) {
    return location.search.search(s) !== -1;
  }

  if (searchContains(/unitType=imperial/i)) {
    var metricLocation =
          location.search.replace(/unitType=imperial/i,
                                      'unitType=metric');
    location.assign(metricLocation);
  } else if (contains(/yummly.com\/recipe\//i) &&
             !searchContains(/unitType=metric/i)) {
    location.search = location.search+'&unitType=metric';
  }
})();