読者です 読者をやめる 読者になる 読者になる

はてブリニューアル後から Minibuffer Bookmark Command ではてブに投稿できなくなってたのでこうした

/lang/javascript/userscripts/minibufferbookmarkcommand.user.js – CodeRepos::Share – Trac

post 用の URL とかが変わってた。

Index: minibufferbookmarkcommand.user.js
===================================================================
--- minibufferbookmarkcommand.user.js	(revision 27521)
+++ minibufferbookmarkcommand.user.js	(working copy)
@@ -63,18 +63,16 @@
 		this.post = function(async, opt){
 			var comment = self.comment;
 			if (self.tags.length) comment = '[' + self.tags.join('][') + ']' + comment;
-			var request = [
-				"mode=enter",
-				"&eid=", opt.eid,
-				"&url=", encodeURIComponent(opt.url),
-				"&rkm=", encodeURIComponent(opt.rkm),
-				"&is_bm=", opt.is_bm,
-				"&title=", encodeURIComponent(opt.title),
-				"&comment=", encodeURIComponent(comment)
-				].join('');
+			opt.comment = comment;
+			var args = [];
+			for (var i in opt) if (opt.hasOwnProperty(i)) {
+				if (i == 'null') continue;
+				args.push(i + "=" + encodeURIComponent(opt[i]));
+			}
+			var request = args.join('&');
 			GM_xmlhttpRequest({
 			  method: 'POST',
-			  url: "http://b.hatena.ne.jp/add",
+			  url: "http://b.hatena.ne.jp/bookmarklet.edit",
 			  headers: {
 				  'Content-Type': 'application/x-www-form-urlencoded'
 				},

これで一応ポストできる、はず。
CodeRepos にコミットできる人、だれかよろしく!!!


タグ取得もできてなかったので、追加。

diff -Naurdp a/minibufferbookmarkcomman.user.js b/minibufferbookmarkcomman.user.js
--- a/minibufferbookmarkcomman.user.js	2009-01-03 12:39:30.000000000 +0000
+++ b/minibufferbookmarkcomman.user.js	2009-01-03 13:13:29.000000000 +0000
@@ -143,7 +143,7 @@ var runMinibufferBookmarkCommand = funct
 					a.ready([]);
 					return;
 				}
-				var tags = $X('//a[@class="tag-latest"]', html);
+				var tags = $X('//a[@class="tag"]', html);
                                 var tag_array = tags.map(function(arg){return arg.textContent});
                                 if (tag_array.length == 0)
                                     window.Minibuffer.status('bookmark.hatena'+self.time,'?B warning: getTags failed!', 3000);


個人的にあててるパッチを全部入れるとこんな感じになる。

Index: minibufferbookmarkcommand.user.js
===================================================================
--- minibufferbookmarkcommand.user.js	(revision 27521)
+++ minibufferbookmarkcommand.user.js	(working copy)
@@ -25,10 +25,11 @@
 // --hatena    -h   ... hatena bookmark
 // --livedoor  -l   ... livedoor clip
 // --delicious -d   ... del.icio.us
-var SBM = '-h'
+var SBM1 = '-l'
+var SBM2 = '-lh'
 
 // for 'b'
-var TAG = ''
+var TAG = 'ToDo'
 
 if(!document.body) return;
 var runMinibufferBookmarkCommand = function(){
@@ -63,18 +64,16 @@
 		this.post = function(async, opt){
 			var comment = self.comment;
 			if (self.tags.length) comment = '[' + self.tags.join('][') + ']' + comment;
-			var request = [
-				"mode=enter",
-				"&eid=", opt.eid,
-				"&url=", encodeURIComponent(opt.url),
-				"&rkm=", encodeURIComponent(opt.rkm),
-				"&is_bm=", opt.is_bm,
-				"&title=", encodeURIComponent(opt.title),
-				"&comment=", encodeURIComponent(comment)
-				].join('');
+			opt.comment = comment;
+			var args = [];
+			for (var i in opt) if (opt.hasOwnProperty(i)) {
+				if (i == 'null') continue;
+				args.push(i + "=" + encodeURIComponent(opt[i]));
+			}
+			var request = args.join('&');
 			GM_xmlhttpRequest({
 			  method: 'POST',
-			  url: "http://b.hatena.ne.jp/add",
+			  url: "http://b.hatena.ne.jp/bookmarklet.edit",
 			  headers: {
 				  'Content-Type': 'application/x-www-form-urlencoded'
 				},
@@ -169,7 +168,7 @@
 				"&postkey=", encodeURIComponent(opt.postkey),
 				"&link=", encodeURIComponent(opt.link),
 				"&tags=", encodeURIComponent(self.tags.join(' ')),
-				"&notes=", encodeURIComponent(self.comment|''),
+				"&notes=", encodeURIComponent(self.comment || ''),
 				].join('');
 			GM_xmlhttpRequest({
 			  method: 'POST',
@@ -521,7 +520,7 @@
 		var target_cmd = '';
 		if(window.location.href == "http://fastladder.com/reader/" ||
 		   window.location.href == "http://reader.livedoor.com/reader/"){
-			target_cmd = 'pinned-or-current-link';
+			target_cmd = 'current-link';
 		}else if(window.scrollY == 0){
 			target_cmd = 'location';
 		}else if(window.LDRize){
@@ -537,14 +536,14 @@
 	  description: 'Bookmark',
 	  command: function(){
 		  var target_cmd = getTargetCommand();
-		  window.Minibuffer.execute(target_cmd + ' | bookmark ' + SBM + ' "--tag=' + TAG + '"');
+		  window.Minibuffer.execute(target_cmd + ' | bookmark ' + SBM1 + ' "--tag=' + TAG + '"');
 	  }});
 	window.Minibuffer.addShortcutkey({
 	  key: 'B',
 	  description: 'Bookmark with tags and comment',
 	  command: function(){
 		  var target_cmd = getTargetCommand();
-		  window.Minibuffer.execute(target_cmd + ' | bookmark ' + SBM + ' --tag --comment');
+		  window.Minibuffer.execute(target_cmd + ' | bookmark ' + SBM2 + ' --tag --comment');
 	  }});
 	window.Minibuffer.addCommand({
 	  name: 'bookmark.update-tags',