パッチのダウンローダ

メニューに install this patchを追加。
debugをonにしてて、右クリックしたのがtombloo.jsで終わるファイルのリンクの時だけ出るリンク以外のとこクリックすると常に出てた。直さない。
実行すると profD/tombloo/script/ にダウンロード。

途中で使い道ないとおもったけど途中だったのでやめるのやめた。

--- browser.xul.orig	2008-07-12 00:17:58.000000000 +0900
+++ browser.xul	2008-07-12 00:48:23.000000000 +0900
@@ -7,6 +7,8 @@
 			 label="Shere...">
 			<menupopup id="tombloo-menu-select"/>
 		</menu>
+		<menuitem insertbefore="context-bookmarklink" 
+			label="Install this patch" id="tombloo-menu-patch" hidden="true" />
 		<menuseparator insertbefore="context-bookmarklink" />
 	</popup>
 	<menupopup id="menu_ToolsPopup">
@@ -59,6 +61,7 @@
 			var menuContext = document.getElementById('contentAreaContextMenu');
 			var menuShare = document.getElementById('tombloo-menu-share');
 			var menuSelect = document.getElementById('tombloo-menu-select');
+			var menuPatch = document.getElementById('tombloo-menu-patch');
 			
 			menuShare.setAttribute('accesskey', env.getPref('accesskey.share'));
 			
@@ -112,8 +115,33 @@
 						item.showForm = true;
 					}
 				}
+
+				if(env.getPref('debug'))
+					menuPatch.hidden = !( context.target.href.match( /\.tombloo\.js$/ ) );
+
 			}, true);
 			
+	if(env.getPref('debug')) {
+			menuPatch.addEventListener('command', function (ev) {
+				var wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+									.createInstance(Ci.nsIWebBrowserPersist);
+
+				var sourceURI = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService)
+													.newURI(context.target.href, null, null);
+				var patchFile = getEnvironment().getPatchDir();
+
+				var leaf = sourceURI.path.split(/\//).pop();
+				patchFile.append(leaf);
+				
+				var wbp = Components.Constructor(
+					'@mozilla.org/embedding/browser/nsWebBrowserPersist;1',
+					'nsIWebBrowserPersist'
+				);
+				wbp().saveURI(sourceURI, null, null, null, null, patchFile);
+				
+			}, false );
+		}
+			
 			menuContext.addEventListener('popuphidden', function(event){
 				if(event.eventPhase != Event.AT_TARGET)
 					return;