Skip to content

Instantly share code, notes, and snippets.

@KenshoFujisaki
Last active September 8, 2015 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KenshoFujisaki/619486797331bf66fb72 to your computer and use it in GitHub Desktop.
Save KenshoFujisaki/619486797331bf66fb72 to your computer and use it in GitHub Desktop.
ページ内のすべてのURLについて,正規表現`url_regex`にマッチするものを紫色で強調
// ページ内のすべてのURLについて,正規表現`url_regex`にマッチするものを紫色で強調
var url_regex = /hatena/;
var iterator = document.evaluate("//a", document, null, 5, null);
var highlighter = function(elm) {
elm.style =
"font-weight:900;" +
"color:white;" +
"background-color:purple;";
};
var node;
while ( node = iterator.iterateNext() ) {
if ( node.href.match(url_regex) ) {
setTimeout(function(_node){highlighter(_node)}, 0, node);
}
}
@KenshoFujisaki
Copy link
Author

vimperator向け -> ページ内のすべてのURLについて,正規表現url_regexにマッチするものを紫色で強調 for vimperator - https://gist.github.com/KenshoFujisaki/768b8f25e0822b8f3974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment