Index: /lang/javascript/userscripts/niconicooldsorter.user.js
===================================================================
--- /lang/javascript/userscripts/niconicooldsorter.user.js (revision 37778)
+++ /lang/javascript/userscripts/niconicooldsorter.user.js (revision 37778)
@@ -0,0 +1,47 @@
+// ==UserScript==
+// @name           双方向ソート in ニコニコ動画
+// @namespace      http://d.hatena.ne.jp/sheile/
+// @description    ニコニコ動画の検索画面に2010/06/01以前の双方向ソートを追加します
+// @include        http://www.nicovideo.jp/search/*
+// ==/UserScript==
+(function() {
+	window.addEventListener("DOMSubtreeModified", function() {
+		var select = document.querySelector("select[name='sort']");
+		if(select == null) return;
+		if(select.options.length > 6) return;
+		
+		var urlList = new Array();
+		for(var i = 0; i < select.options.length; i++) {
+			urlList.push(select.options[i]);
+		}
+		
+		for(var i = 0; i < urlList.length; i++) {
+			insertOption(select, urlList[i]);
+		}
+	}, false);
+	
+	function insertOption(select, option)
+	{
+		var isDesc = option.value.match(/order=d$/) != null;
+		var newOption = document.createElement("option");
+		if(isDesc) {
+			newOption.value = option.value.replace(/order=d$/, "order=a");
+		} else {
+			newOption.value = option.value.replace(/order=a$/, "order=d");
+		}
+		
+		var text = option.text;
+		if(!isDesc) {
+			text = text.replace("古い", "新しい");
+			text = text.replace("少ない", "多い");
+			text = text.replace("短い", "長い");
+		} else {
+			text = text.replace("新しい", "古い");
+			text = text.replace("多い", "少ない");
+			text = text.replace("長い", "短い");
+		}
+		
+		newOption.text = text;
+		select.insertBefore(newOption, isDesc ? option : option.nextSibling);
+	}
+})();
