2008-03-14

[][]はてブhotentryにて2chコピペブログや「ネタ」を削除

http://anond.hatelabo.jp/20080302214727

ネタ」がうまくいかない件は、"\u30cd\u30bf"にしたらうまく行った

あと2chコピペサイトを2つ追加

とりあえず、Sleipnir2のSeahorseで確認。

// ==UserScript==
// @name           hatebufilter
// @namespace      hatebufilter
// @description    Hatena bookmark filter
// @include        http://b.hatena.ne.jp/hotentry*
// @include        http://b.hatena.ne.jp/entrylist*
// ==/UserScript==
/*
問題点
いまのところなし

・問題が起こりそうなURL
http://b.hatena.ne.jp/hotentry?mode=daily&date=20080224
http://b.hatena.ne.jp/hotentry?mode=daily&date=20080218
**/

(function(){
	// Hatebu Tag
	var HatebuTagParentNum = 3;

	var filters = [
		// moconico douga
		{"tag": "div", "name": "entry", "pattern": "nicovideo\.jp"},
/*
		// tag of "2ch"
		{"tag": "a", "name": "tag", "pattern": "2ch", "parentNum": HatebuTagParentNum},
		{"tag": "a", "name": "tag", "pattern": "\\*2ch", "parentNum": HatebuTagParentNum},
**/
		// 2ch blogs  
		//  livedoor
		{"tag": "div", "name": "entry",
			"pattern": /http:\/\/blog\.livedoor\.jp\/(insidears|dqnplus)\//},
		{"tag": "div", "name": "entry",
			"pattern": /http:\/\/(guideline|alfalfa|news4vip)\.livedoor\.biz\//},
		//  fc2
		{"tag": "div", "name": "entry",
			"pattern": /http:\/\/(imihu|urasoku|news23vip|waranote|vipvipblogblog|netanabe|res2ch|kanasoku|tenkomo)\.blog\d+\.fc2\.com\//},
		{"tag": "div", "name": "entry",
			"pattern": /http:\/\/www\.kajisoku\.org\//},
		
		// hatena anonymouse diary
		{"tag": "div", "name": "entry", "pattern": /http:\/\/anond\.hatelabo\.jp\//},

		// tag of "neta"
		{"tag": "a", "name": "tag", "pattern": "\u30cd\u30bf", "parentNum": HatebuTagParentNum},
		{"tag": "a", "name": "tag", "pattern": "\\*\u30cd\u30bf", "parentNum": HatebuTagParentNum},
	];

	for (var i = 0; i < filters.length; i++) {
		var f = filters[i];
		filtering(f.tag, f.name, f.pattern, f.parentNum== undefined ? 1 : f.parentNum);
	}

	function filtering(tag, name, pattern, parentNodeNum){
		var entrylist = document.getElementsByTagName(tag);
                //print("pattern = " + pattern);
		for(var idx = entrylist.length - 1; 0 <= idx; idx--){
//        for(var idx = 0; idx < entrylist.length - 1; idx++){
			if (entrylist[idx].className == name){
				if (entrylist[idx].innerHTML.match(pattern)) {
					var node = entrylist[idx];
					var oldNode = null;
					for (var j = 0; j < parentNodeNum; j++) {
						oldNode = node;
						node = node.parentNode;
					}
					// print("class = " + oldNode.getAttribute("class"));
					// print("id = " + oldNode.getAttribute("id"));
					node.removeChild(oldNode);
				}
			}
		}
	}
})();
記事への反応 -

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

アーカイブ ヘルプ
ログイン ユーザー登録
ようこそ ゲスト さん