Movatterモバイル変換


[0]ホーム

URL:


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

2008-01-01

はてブニコニコ動画へのブックマークがうざすぎる

アイドルマスターとか初音ミクとか。

なのでJavaSciptの勉強がてら、ニコニコ動画関連のブックマークを見えなくするユーザースクリプトを作った。DOMがよくわからないので変なところがあるかも。スコープノードリストなんかもよくわかってないので、無駄なところもあるかも。

以下ソース

Opera
// ==UserScript==// @name      NicoNico Eraser// @include   http://b.hatena.ne.jp/entrylist*// @authorHatena AnonymousUser MASUDA// @version   0.0.1// ==/UserScript==(function(){    document.onload = main;            function main(){        var entryList = filterByTagAndClass("div", "entry");                checkAndErase(entryList);    }            function filterByTagAndClass(tag,name){        var list = document.getElementsByTagName(tag);        var newList = [];                for(var i = 0; i < list.length; i++){            if(list[i].className ==name){                newList.push(list[i]);            }        }                return newList;    }            function checkAndErase(nodeList){        for(var i=0; i < nodeList.length; i++){            var elem = nodeList[i].getElementsByTagName("a")[0];                        if(elem.href.substring(0,30) == "http://www.nicovideo.jp/watch/"){                nodeList[i].parentNode.removeChild(nodeList[i]);            }                    }    }})();

Firefox(Greasemonkey)
// ==UserScript==// @name          NicoNico Eraser// @include       http://b.hatena.ne.jp/entrylist*// @description   version:0.0.1// ==/UserScript==main();function main(){    var entryList = filterByTagAndClass("div", "entry");        checkAndErase(entryList);}function filterByTagAndClass(tag,name){    var list = document.getElementsByTagName(tag);    var newList = [];        for(var i = 0; i < list.length; i++){        if(list[i].className ==name){            newList.push(list[i]);        }    }        return newList;}function checkAndErase(nodeList){    for(var i=0; i < nodeList.length; i++){        var elem = nodeList[i].getElementsByTagName("a")[0];                if(elem.href.substring(0,30) == "http://www.nicovideo.jp/watch/"){            nodeList[i].parentNode.removeChild(nodeList[i]);        }    }}

まぁ、これだと初音ミクアイドルマスター以外の動画も見えなくなるんだけどね。

つーかJavaScriptだとPythonみたいなfor文使えないの?

Permalink |記事への反応(2) | 23:28

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

記事への反応 -

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

全てのコメントを見る

人気エントリ

注目エントリ

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

[8]ページ先頭

©2009-2025 Movatter.jp