--- heatthenicovideoup.user.js	Tue May 20 19:48:07 2008
+++ heatthenicovideoupfix.user.js	Tue May 20 20:51:45 2008
@@ -1,12 +1,14 @@
 // ==UserScript==
-// @name           Heat the nicovideo up
+// @name           Heat the nicovideo up fix
+// @author         mtamaki
 // @author         noriaki
+// @namespace      http://mtamaki.com/
 // @namespace      http://blog.fulltext-search.biz/
 // @description    Visualize comments upsurge for Nicovideo
 // @license        MIT License
-// @version        0.3.4
+// @version        0.3.4.1
 // @released       2007-09-11 09:00:00
-// @updated        2008-01-26 21:00:00
+// @updated        2008-05-19 00:00:00
 // @compatible     Greasemonkey
 // @include        http://www.nicovideo.jp/watch/*
 // ==/UserScript==
@@ -27,6 +29,9 @@
  * http://sourceforge.jp/projects/opensource/wiki/licenses%2FMIT_license (Japanese)
 */
 
+(function(){
+
+function main() {
 var COLOR_MAP = [
     '#060026', '#0f0082', '#181395', '#214dd6',
     '#3b8cd2', '#36b9d3', '#34c5a5', '#41cc27',
@@ -410,20 +415,23 @@
     commentsCountArea($('heat_info'), spans[index], percent_video_moving);
 }
 
-var PE = unsafeWindow.PeriodicalExecuter;
 var ready = /l=\d+&/;
-var waiting =new PE(function() {
-    var frequency = wait_ready();
-    var nico = $('flvplayer').GetVariable('nico.o');
-    if(frequency > 0) {
-        this.callback = follow_seek_bar;
-        this.frequency = frequency;
-        heat_map();
-    } else if(nico && ready.test(nico)) {
-        waiting.stop();
-        update_for_flv();
-    }
-}, 0.5);
+(function waiting() {
+	var frequency = wait_ready();
+	var nico = $('flvplayer').GetVariable('nico.o');
+	if(frequency > 0) {
+		(function call_follow_seek_bar(){
+			follow_seek_bar();
+			setTimeout(call_follow_seek_bar, frequency * 1000)
+		})()
+		heat_map();
+		return
+	} else if(nico && ready.test(nico)) {
+		update_for_flv();
+		return
+	}
+	setTimeout(waiting, 500)
+})()
 
 function update_for_flv() {
     var info = document.createElement('div');
@@ -764,3 +772,32 @@
     GM_setValue('last_check_day', "Thu Jan 01 1970 00:00:00 GMT+0900");
 var user_script = new UpdateChecker();
 user_script.check_update();
+
+}	//function main()
+
+window.addEventListener("load",
+	function(){
+		var id = "heatthenicovideoupfix"
+		if(document.getElementById(id))
+			return
+		var element = document.createElement("span");
+		element.id = id
+		document.body.appendChild(element);
+
+		if(!unsafeWindow.Prototype) {
+			var script_tag = document.createElement( "script" );
+			script_tag.src = "http://www.prototypejs.org/assets/2007/6/20/prototype.js";
+			document.body.appendChild( script_tag );
+			(function wait() {
+				if(unsafeWindow.Prototype)
+					main()
+				else
+					setTimeout(wait, 500)
+			})()
+		} else
+			main()
+	},
+	false
+)
+
+})()
