2007-06-08

ついカッとなってやった

20070629230000改定

20070702125800バグ発見スクリプト中にある「&&」が、「&&」になっている。増田仕様らしい。

20070827224900改定

// ==UserScript==
// @name	anond pickup
// @namespace	http://anond.hatelabo.jp/20070608230645
// @description	pickup trackback tree top section at Hatelabo::AnonymousDiary
// @include	http://anond.hatelabo.jp/*
// ==/UserScript==
(function() {
	var threshold_bm = 1;
	var threshold_tb = 1;
	var ignoreList = {
		"/20070801172335": 33,
		"/20070806163721": 10,
	};
	var firstPager_l = document.evaluate("//div[@class='pager-l']",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;

	function Hide(){}
	Hide.prototype.setup = function() {
		this.style = document.createElement("style");
		this.style.id = "hide";
		this.style.type = "text/css";
		document.getElementsByTagName("head")[0].appendChild(this.style);
		var self = this;
		this.a = new Object();
		this.a.visible = document.createElement("a");
		this.a.visible.id = "visible";
		this.a.visible.href = "#";
		this.a.visible.innerHTML = "visible hide section";
//		this.a.visible.setAttribute("onclick","document.getElementById('hide').innerHTML = 'div.hide {display: block}';document.getElementById('visible').style.display = 'none';document.getElementById('unvisible').style.display = 'inline';");
		this.a.visible.addEventListener("click", function(){self.visible()}, false);
		firstPager_l.parentNode.insertBefore(this.a.visible, firstPager_l);
		this.a.unvisible = document.createElement("a");
		this.a.unvisible.id = "unvisible";
		this.a.unvisible.href = "#";
		this.a.unvisible.innerHTML = "unvisible hide section";
//		this.a.visible.setAttribute("onclick","document.getElementById('hide').innerHTML = 'div.hide {display: none}';document.getElementById('visible').style.display = 'inline';document.getElementById('unvisible').style.display = 'none';");
		this.a.unvisible.addEventListener("click", function(){self.unvisible()}, false);
		firstPager_l.parentNode.insertBefore(this.a.unvisible, firstPager_l);
		if (GM_getValue("visible", 0)) {
			this.visible();
		} else {
			this.unvisible();
		}
	}
	Hide.prototype.visible = function() {
		this.style.innerHTML = "div.hide {display: block}";
		this.a.visible.style.display = "none";
		this.a.unvisible.style.display = "inline";
		GM_setValue("visible", 1);
	}
	Hide.prototype.unvisible = function() {
		this.style.innerHTML = "div.hide {display: none}";
		this.a.visible.style.display = "inline";
		this.a.unvisible.style.display = "none";
		GM_setValue("visible", 0);
	}
	Hide.prototype.append = function(section) {
		if (section.className.match(/hide/)) {
			return;
		}
		section.className += " hide";
	}
	Hide.prototype.clear = function(section) {
		section.className = section.className.replace(/ hide/g, "");
	}
	Hide.prototype.is = function(section) {
		return section.className.match(/hide/);
	}
	var hide = new Hide();
	hide.setup();

	var target = document.evaluate(
		"//div[@class='section' and child::*[not(@class='sectionfooter') and descendant::a[starts-with(@href,'http://anond.hatelabo.jp/2') or starts-with(@href,'/2') and not(child::span[@class='sanchor'])]]]",
		document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
	for (var i=0; i<target.snapshotLength; i++) {
		hide.append(target.snapshotItem(i));
	}

	var tbs = document.evaluate(
		"//p[@class='sectionfooter']/a[2]",
		document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
	for (var i=0; i<tbs.snapshotLength; i++) {
		var tb = tbs.snapshotItem(i);
		if (tb.innerHTML == "\u30c8\u30e9\u30c3\u30af\u30d0\u30c3\u30af(0)") {
//			hide.append(tb.parentNode.parentNode);
			bookmark(tb, 0);
		} else if (! hide.is(tb.parentNode.parentNode)) {
			trackback(tb, 1);
		} else {
			bookmark(tb, 1);
		}
	}

	function trackback(tb, callback) {
		GM_xmlhttpRequest({
			method: "GET",
			url: "http://anond.hatelabo.jp/" + tb.pathname.match(/\d{14}/),
			onload: function(result) {
				var link = result.responseText.match(/<a name="tb">(.|\s)*/)[0].match(/<li>\s*<a href="http:\/\/anond.hatelabo.jp\/\d{14}"/g);
				var n = link.length;
				for (var l in link) {
					var m = "/" + link[l].match(/\d{14}/);
					if (m in ignoreList) {
						n -= ignoreList[m];
					}
				}
				if (n < threshold_tb) {
					tb.innerHTML = tb.innerHTML.replace(/\)$/, "/"+n+")");
					if (callback) {
						bookmark(tb);
					}
				} else {
					tb.innerHTML = tb.innerHTML.replace(/\)$/, '/<span style="color: red;">'+n+"</span>)");
				}
			}
		});
	}

	function bookmark(tb, callback){
		GM_xmlhttpRequest({
			method: "GET",
			url: "http://b.hatena.ne.jp/entry/rss/http://anond.hatelabo.jp/" + tb.pathname.match(/\d{14}/),
			onload: function(result) {
				var r = result.responseText.match(/<rdf:li rdf:resource=/g);
				if (r &amp;&amp; r.length >= threshold_bm){
					hide.clear(tb.parentNode.parentNode);
					if (callback) {
						trackback(tb);
					}
				} else {
					hide.append(tb.parentNode.parentNode);
				}
			}
		});
	}
})();

今はスッキリしているのは古いやつ

/// ==UserScript==
// @name	anond pickup
// @namespace	http://anond.hatelabo.jp/20070608230645
// @description	pickup trackback tree top section at Hatelabo::AnonymousDiary
// @include	http://anond.hatelabo.jp/*?page=*
// ==/UserScript==
(function() {
	var target = document.evaluate(
		"//div[@class='section' and child::*[not(@class='sectionfooter') and descendant::a[starts-with(@href,'http://anond.hatelabo.jp/2') or starts-with(@href,'/2') and not(child::span[@class='sanchor'])]]]",
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);
	for(var i=0; i<target.snapshotLength; i++) {
		target.snapshotItem(i).style.display = "none";
	}

	var trackback = document.evaluate(
		"//p[@class='sectionfooter']/a[2]",
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);
	for(var i=0; i<trackback.snapshotLength; i++) {
		if (trackback.snapshotItem(i).innerHTML == "\u30c8\u30e9\u30c3\u30af\u30d0\u30c3\u30af(0)") {
			trackback.snapshotItem(i).parentNode.parentNode.style.display = "none";
		} else if (trackback.snapshotItem(i).parentNode.parentNode.style.display != "none") {
			count(trackback.snapshotItem(i));
		}
	}

	function count(tb) {
		GM_xmlhttpRequest({
			method: "GET",
			url: "http://anond.hatelabo.jp/" + tb.getAttribute("href").match(/[0-9]{14}/),
			onload: function(result) {
				var n = result.responseText.replace(/\n/g,"").match(/<a name="tb">.*/)[0].match(/<li>/g).length;
				if (n < 10) {
					tb.innerHTML = tb.innerHTML.replace(/\)$/,"/"+n+")");
				} else {
					tb.innerHTML = tb.innerHTML.replace(/\)$/,'/<span style="color: red;">'+n+"</span>)");
				}
			}
		});
	}
})();
  • トラバが付いてる増田だけピックアップか。 個人的には、グリモンで[トラバを書く]ボタンを出すボタンが欲しい。 クリックすると、editに移動して、タイトルにクリックした元増田先の...

  • 記事の抽出の基本はRe: 増田の読み方ってどうしてますか?による。 沢山ブックマークされている記事は閾値10から取得 トラックバックの沢山ついている記事はanond pickupを使用 一つ...

    • 今日のはてブに上がったのは嘘を嘘と見抜けない人は(ryである。しかし、webサービスがいくら増えてもねと嘆く増田がいうように、時間はかぎられ、で、という勘違いもなくせない。...

      • http://anond.hatelabo.jp/20070609184229 なぜ結婚したのか。と聞くのはたぶん、女友達を作るにはどうすればいいのかという疑問と同じようなものだろう。なんでそう思える相手がいるのか、ど...

    • 効率的にやってもこんなに手間がかかるんだ。 日刊増田の増田さんたちどうもありがとう!!いつも楽しませてもらってます。

    • エディタで書いてるとタイトル見えなくてわけわからなくなるな。ちょくちょくプレビューしながら書いてた。やたら大量に拾っちゃうのは自分の基準で拾っていいもんかわからんから拾...

      • 確認してみた。 http://anond.hatelabo.jp/20070609194031 anond:20070609194031 は &lt;li&gt;&lt;a href=&quot;http://anond.hatelabo.jp/20070609194031&quot;&gt;http://anond.hatelabo.jp/20070609194031&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quo...

記事への反応(ブックマークコメント)

ログイン ユーザー登録
ようこそ ゲスト さん