同一ドメインのリンクをハイライトさせるブックマークレット

This page's been moved to the blog below.
この記事は次のブログに引っ越しました。

同一ドメインのリンクに色をつけるGreasemonkey 某動画のナビゲーターサイトなどから、オススメのサイトを訪問する際に時々思うのですが、アフィリエイト・サイトなど、リンク集の中に目的のページが埋もれていて目的のリンクをあえて探しづらくしているサイトがあります。シンプルでいいから、同じドメインのリンクを反転なりCSSで色をつけてくれるブックマークレットFirefoxプラグインを探していたら、どんぴしゃのグリースモンキーのユーザスクリプトを見つけた。
I found a simple Greasemonkey user script that highlights the anchor(links) with the same domain wich you are visiting. It is useful when you are looking for a link with the same domain, within a huge list of links.
すぐに忘れる脳みそのためのメモ Greasemonkey で特定のリンクをハイライト
http://jutememo.blogspot.com/2008/09/greasemonkey.html
同一ドメイン内の動画やZIPファイルのみをハイライトするスクリプト 上記スクリプトを少し改造してみました。同一ドメインのリンクは赤色で反転、別ドメインでも、リンクの末尾が動画やZIPの場合は青色でハイライトしています。 何に使うのかって?いや、まぁ。いいじゃないですか。// ==UserScript==// @name HighlightSameSite // @namespace highlightsamesite.greasemonkey.keinos.com // @description 同一サイト内のリンクをハイライトさせる // @include http://* // ==/UserScript== (function() { var INCLUDE_REGEXP = "^" + location.protocol + "//" + location.hostname + ".*()"; var EXCLUDE_REGEXP = "out"; var EXTRA_REGEXP = "(wmv|zip|rm|avi)$"; function highlightElem(e){ with(e.style){ backgroundColor = "#fcc" borderColor = "#f00"; borderStyle = "solid"; borderWidth = "3px"; color = "black";
} } function highlightElem2(e){ with(e.style){ backgroundColor = "#ccf" borderColor = "#00f"; borderStyle = "solid"; borderWidth = "3px"; color = "black"; } } function createExcludeRegExp(){ return EXCLUDE_REGEXP ? new RegExp(EXCLUDE_REGEXP) : null; } function highlight(re, notRe, extra){ var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++){ href = anchors[i].href; if ( (!href.match(re) || href.match(notRe)) && !href.match(extra) ) continue; if (href.match(extra)){ highlightElem2(anchors[i]); } else{ highlightElem(anchors[i]); } } } highlight(new RegExp(INCLUDE_REGEXP), createExcludeRegExp(), RegExp(EXTRA_REGEXP) )})(); ※Greasemonkey(グリースモンキー)について調べる(Google)