Clear Radio Button

When clicking on a selected radio button, this script will clear it

La data de 03-06-2014. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// Clear Radio Button
// version 0.1 BETA!
// 2006-11-28
// by Jim Biancolo
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Show Cell Headers", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          Clear Radio Button
// @version       0.1
// @namespace     http://www.biancolo.com
// @description   When clicking on a selected radio button, this script will clear it
// @include       *
// ==/UserScript==

(function() {

  var currRadioRef = null;
  var currRadioVal = null;

  function clearRadio(event) {
    var t = event.target;

    if (isRadio(t)) {
      if ((currRadioRef==t) && currRadioVal) {
        t.checked = false;
        currRadioRef = null;
      }
    }
  }

  function getRadioState(event) {
    var t = event.target;
    
    if (isRadio(t)) {
      currRadioRef = t;
      currRadioVal = t.checked;
    }
  }

  function isRadio(ctrl) {
    return (ctrl.tagName.toUpperCase() == "INPUT" && ctrl.type == "radio");
  }

  document.documentElement.addEventListener("mousedown", getRadioState, true);
  document.documentElement.addEventListener("click", clearRadio, true);

})();