SnowStorm Killer

By piouPiouM Last update Dec 31, 2008 — Installed 161 times.

There are 2 previous versions of this script.

// ==UserScript==
// @name           SnowStorm Killer
// @namespace      http://pioupioum.fr
// @description    Remove "Snow Storm" effect added by Snowstorm script.
// @version        1.1
// @author         Mehdi Kabab
// @include        *
// ==/UserScript==
/*
# ***** BEGIN LICENSE BLOCK *****
# Copyright (C) 2008 Mehdi Kabab <http://pioupioum.fr/>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# ***** END LICENSE BLOCK ***** */

(function(){
	var SnowStormKiller = function() {
		const NO_SNOWSTORM = -1, SNOWSTORM_12 = 0, SNOWSTORM_13 = 1;
		var s;

		function checkScript() {
			var ret = NO_SNOWSTORM;
			
			if ('function' == typeof unsafeWindow.SnowStorm)
			{
				// Detect version 1.2
				if ('function' == typeof unsafeWindow.snowStormInit)
				{
					ret = SNOWSTORM_12;
				}
				// version 1.3
				else
				{
					s = unsafeWindow.snowStorm;
					
					if ('object' == typeof s && 'function' == typeof s.stop)
					{
						ret = SNOWSTORM_13;
					}
				}
			}
			
			return ret;
		}; // checkScript

		function forceReset() {
			unsafeWindow.SnowStorm = function() {};
		}; // forceReset

		function process() {
			var flakes = s.flakes, h;
			
			if (0 === flakes.length)
				return;
			
			s.stop();
			
			h = flakes[0].o.parentNode;
			for (var i = 0, f; f = flakes[i++];)
			{
				h.removeChild(f.o);
			}
			
			s = unsafeWindow.snowStorm = undefined;
			forceReset();
		}; // process

		return {
			init: function() {
				switch (checkScript())
				{
					case SNOWSTORM_13:
						process();
						break;
					case SNOWSTORM_12:
						forceReset();
						break;
					case NO_SNOWSTORM:
					default:
						return;
				}
			} // init
		};
	}();

	SnowStormKiller.init();
})();