Movatterモバイル変換


[0]ホーム

URL:


はてラボはてな匿名ダイアリー
ようこそ ゲスト さんログインユーザー登録
< http://anond.hatelabo.jp/20080... |http://anond.hatelabo.jp/20080... >

2008-03-08

[greasemonkey][greasemonkey][seahorse]はてブのhotentryで、2chコピペブログや「ネタ」を削除す...勝手に改造

firefoxでしか確認していないけれど、URL正規表現XPathで指定できる様にしてみたよ。

// ==UserScript==// @name           filter forHatena::Bookmark// @namespacehttp://anond.hatelabo.jp/// @includehttp://b.hatena.ne.jp/hotentry*// @includehttp://b.hatena.ne.jp/entrylist*// originhttp://anond.hatelabo.jp/20080302214727// ==/UserScript==(function(){var itemxpath = "//div[@class='entry']";function xpathgenURL(url) {return "//div[@class='entry' and descendant::a[starts-with(@href,'"+url+"')]]"}var filters = [// start with '//' thenxpath// moconico douga//{"tag": "div", "name": "entry", "pattern": "nicovideo\.jp"},"//div[@class='entry' and descendant::a[contains(@href,'nicovideo.jp')]]",/*//tag of "2ch"{"tag": "a", "name": "tag", "pattern": "2ch", "parentNum": HatebuTagParentNum},{"tag": "a", "name": "tag", "pattern": "\\*2ch", "parentNum": HatebuTagParentNum},***/// start with 'http' thenurl//2ch blogs  //livedoor//{"tag": "div", "name": "entry",//"pattern": /http:\/\/blog\.livedoor\.jp\/(insidears|dqnplus)\//},"http://blog.livedoor.jp/insidears/","http://blog.livedoor.jp/dqnplus/",//{"tag": "div", "name": "entry",//"pattern": /http:\/\/(guideline|alfalfa|news4vip)\.livedoor\.biz\//},"http://guideline.livedoor.biz/","http://alfalfa.livedoor.biz/","http://news4vip.livedoor.biz/",// typeof /regexp/ is function (@firefox) thenregexp pattern//fc2//{"tag": "div", "name": "entry",//"pattern": /http:\/\/(urasoku|news23vip|waranote|vipvipblogblog|netanabe|res2ch|kanasoku|tenkomo)\.blog\d+\.fc2\.com\//},/http:\/\/(urasoku|news23vip|waranote|vipvipblogblog|netanabe|res2ch|kanasoku|tenkomo)\.blog\d+\.fc2\.com\//,//tag of "neta"//{"tag": "a", "name": "tag", "pattern": "ネタ", "parentNum": HatebuTagParentNum},"//div[@class='entry' and descendant::a[@class='tag' andstring()='ネタ']]",//{"tag": "a", "name": "tag", "pattern": "*ネタ", "parentNum": HatebuTagParentNum},"//div[@class='entry' and descendant::a[@class='tag' andstring()='*ネタ']]",//hatena anonymouse diary//{"tag": "div", "name": "entry", "pattern": /http:\/\/anond\.hatelabo\.jp\//}"http://anond.hatelabo.jp/",];for (var i=0; i<filters.length; i++) {var filter = filters[i];var type = typeof filter;varregexp;varxpath;if (type == "function") {xpath = itemxpath;regexp = filter;} else if (type == "string") {if (filter.match(/^http/)) {xpath = xpathgenURL(filter);} else if (filter.match(/^\/\//)) {xpath = filter;} else {next;}}var removeNodes = document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for (var j=0; j<removeNodes.snapshotLength; j++) {var node = removeNodes.snapshotItem(j);if (!regexp || node.innerHTML.match(regexp)) {node.parentNode.removeChild(node);}}}})();

ついでに増田版も作ってみたよ。

// ==UserScript==// @name           filter for Hatelabo::AnonymousDiary// @namespacehttp://anond.hatelabo.jp/// @includehttp://anond.hatelabo.jp/// @includehttp://anond.hatelabo.jp/*?page=*// @excludehttp://anond.hatelabo.jp/YourID/*// ==/UserScript==// originhttp://anond.hatelabo.jp/20080302214727(function(){var itemxpath = "//div[@class='section']";function xpathgenURL(url) {return "//div[@class='section' and descendant::a[starts-with(@href,'"+url+"')]]"}var filters = [// start with '//' thenxpath"//div[@class='section' and child::h3[starts-with(string(),'■はてな嫌われ者!')]]",// start with 'http' thenurl"http://anond.hatelabo.jp/",// typeof /regexp/ is function (@firefox) thenregexp pattern/釣り/,];for (var i=0; i<filters.length; i++) {var filter = filters[i];var type = typeof filter;varregexp;varxpath;if (type == "function") {xpath = itemxpath;regexp = filter;} else if (type == "string") {if (filter.match(/^http/)) {xpath = xpathgenURL(filter);} else if (filter.match(/^\/\//)) {xpath = filter;} else {next;}}var removeNodes = document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for (var j=0; j<removeNodes.snapshotLength; j++) {var node = removeNodes.snapshotItem(j);if (!regexp || node.innerHTML.match(regexp)) {node.parentNode.removeChild(node);}}}})();

Permalink |記事への反応(2) | 20:06

このエントリーをはてなブックマークに追加ツイートシェア

記事への反応 -

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

全てのコメントを見る

人気エントリ

注目エントリ

ログインユーザー登録
ようこそ ゲスト さん
Copyright (C) 2001-2025 hatena. All Rights Reserved.

[8]ページ先頭

©2009-2025 Movatter.jp