Table of Contents

Wayback Machine:http://www.archive.org/web/web.phpで現在表示しているサイトの過去のアーカイブを見る

javascript: location = 'http://web.archive.org/web/*/' + location.href

Google Cache から現在表示しているサイトの過去のアーカイブを見る

javascript: location = 'http://webcache.googleusercontent.com/search?q=cache:' 
	+ encodeURIComponent(location.href.replace(/^http:\/\//,''));

Google翻訳:http://translate.google.com/でサイトを翻訳

javascript: location = 'http://translate.google.com/translate?sl=auto&tl=ja&u=' 
	+ encodeURIComponent(location.href);

Google検索へのリンク(PukiWiki 用)

javascript: (function () {
var types = {
	'isch': 'Image', 'vid': 'Video', 'nws': 'News', 'bks': 'Books',
};
var target = location.hash || location.href;
var type = '';
if (location.pathname != '/maps') {
	target.match(/[\?&#]tbm=([^&#]+)/);
	type = RegExp.$1 || '';
	type = (types[type]) 
		? types[type] 
		: type.charAt(0).toUpperCase() + type.slice(1);
} else {
	type = 'Maps';
}
target.match(/[\?&#]q=([^&#]+)/);
var query = decodeURIComponent(RegExp.$1.replace(/\+/g, ' ') || '').replace(/\u3000/g, ' ');
prompt(
	'Google Link\nType:\t' + type + '\nQuery:\t' + query, 
	'[[Google' + type + ':' + query + ']]'
);
})();

MSDN の言語指定を変更

  • en -> ja
    javascript: location = location.href.replace(/\/en-us\//i, '/ja-jp/');
  • ja -> en
    javascript: location = location.href.replace(/\/ja-jp\//i, '/en-us/');

MSDN のバージョン指定を削除

javascript: location = location.href.replace(/\(.*?\)(\.aspx)/i, '$1');

Web Sniffer:http://web-sniffer.net/で現在表示しているサイトのhttpリクエストヘッダ/レスポンスヘッダを確認する

javascript: location = 'http://web-sniffer.net/?url=' + encodeURIComponent(location.href)

現在のページのタイトルをポップアップで表示

javascript: void(function(){prompt(document.title, document.title);})()

現在のページのタイトルとURLをポップアップで表示

javascript: void(function () {
	var title = document.title.replace(/\|/g, '-');
	var uri = location.href;
	prompt(title + '\n' + uri, title + '\n' + uri + '\n');
})()

現在のページのタイトルとURLをポップアップで表示(PukiWiki用)

javascript: void(function () {
	var title = document.title.replace(/\|/g, '-');
	var uri = location.href;
	prompt(title + '\n' + uri, '[[' + title + ':' + uri + ']]');
})()

現在のページのタイトルとURLをポップアップで表示(Markdown用)

javascript: (function(title, uri) {
	prompt(title + '\n' + uri, '[' + title + '](' + uri + ')');
})(document.title, location.href);

現在の画像のファイル名とURLをポップアップで表示(Markdown Image用)

javascript: (function(uri) {
	uri.match(/([^\/\\]+)\.[0-9A-Za-z]+$/);
	var title = RegExp.$1;
	prompt(title + '\n' + uri, '![' + title + '](' + uri + ' "' + title + '")');
})(location.href);

1つ上のフォルダに移動

javascript: location = location.href.replace(/[^\/]*\/?$/, '');

前のページに移動

javascript: location = location.href.replace(/([0-9]+)([^0-9]*)$/, function(whole, p1, p2) {
    return (p1 - 1) + p2;
});

次のページに移動

javascript: location = location.href.replace(/([0-9]+)([^0-9]*)$/, function(whole, p1, p2) {
    return (p1 - 0 + 1) + p2;
});

Locationオブジェクトのプロパティを表示

javascript: (function () {
var result = '<table border="1">\n<tr><th>Property</th><th>Type</th><th>Value</th></tr>\n';
for (var p in location) {
	if (p == 'href' || p == 'search' || p == 'hash') {
		var param = location[p].replace(/([\?&#])/g, '<br>$1');
		result += '<tr><td>' + p + '</td><td>' + typeof (location[p]) + '</td><td>' + param + '</td></tr>\n';
	} else {
		result += '<tr><td>' + p + '</td><td>' + typeof (location[p]) + '</td><td>' + location[p] + '</td></tr>\n';
	}
};
result += '</table>';
var docNew = window.open('', '_blank').document;
docNew.open('text/html');
docNew.write('<html><body>\n' + result + '</body></html>');
docNew.close();
})();

flashvarsの値を表示

javascript: (function () {
	var flashvars = '';
	var elmParams = document.getElementsByTagName('param');
	if (elmParams.length) {
		for (var i = 0; i < elmParams.length; ++i) {
			if (elmParams[i].getAttribute('name') == 'flashvars') {
				flashvars += decodeFlashVars(elmParams[i].getAttribute('value'));
			}
		}
	}
	var elmEmbeds = document.getElementsByTagName('embed');
	if (elmEmbeds.length) {
		for (var i = 0; i < elmEmbeds.length; ++i) {
			var value;
			if (value = elmEmbeds[i].getAttribute('flashvars')) {
				flashvars += decodeFlashVars(value);
			}
		}
	}
	if (flashvars != '') {
		var oWin = window.open('', '_blank');
		oWin.document.open('text/html');
		oWin.document.write('<html><body>\n' + flashvars + '</body></html>');
		oWin.document.close();
	} else {
		alert('flashvars not found');
	}

	function decodeFlashVars(flashvar) {
		var params = flashvar.split(/&/).sort();
		var result = '<table border="1">\n<tr><th>Key</th><th>Value</th></tr>\n';
		for (var i = 0; i < params.length; ++i) {
			var kv = params[i].split(/=/);
			result += '<tr><td>' + kv[0] + '</td>';
			result += '<td>' + decodeURIComponent(kv[1] || '') + '</td></tr>\n';
		}
		result += '</table>\n';
		return result;
	}
})();

現在のDOMを表示

javascript: (function () {
	var strXML = new XMLSerializer().serializeToString(document.documentElement);
	var docNew = window.open().document;
	docNew.open('text/html; charset="UTF-8"').write(htmlEscape(strXML).replace(/[\r\n]+/g, '<br>'));
	docNew.close();

	function htmlEscape(s) {
		return s.replace(/[&<>"']/g, function (m) {
			return '&#x' + m.charCodeAt(0).toString(16) + ';'
		});
	}
})();

現在のページの Cookie を表示

javascript: (function() {
  var html = '';
  html += '<html><body>';
  html += '<table border="1">';
  html += '<tr><th>key</th><th>value</th></tr>';
  var pairs = document.cookie.split(/\s*;\s*/);
  for (var i = 0, pair; pair = pairs[i]; ++i) {
    pair.match(/^\s*([^=]+)\s*=\s*(.*)\s*$/);
    html += '<tr><td>' + decodeURIComponent(RegExp.$1) + '</td><td>' + decodeURIComponent(RegExp.$2) + '</td></tr>';
  }
  html += '</table>';
  html += '</body></html>';
  var docNew = window.open('', '_blank').document;
  docNew.open('text/html; charset=UTF-8');
  docNew.write(html);
  docNew.close();
})();

現在のページの localStorage を表示

javascript: (function() {
  var html = '';
  html += '<html><body>';
  html += '<table border="1">';
  html += '<tr><th>key</th><th>value</th></tr>';
  for (var key in localStorage) {
    html += '<tr><td>' + decodeURIComponent(key) + '</td><td>' + decodeURIComponent(localStorage[key]) + '</td></tr>';
  }
  html += '</table>';
  html += '</body></html>';
  var docNew = window.open('', '_blank').document;
  docNew.open('text/html; charset=UTF-8');
  docNew.write(html);
  docNew.close();
})();

リンクされているzipやlzh、pdfをリストアップ

  • Opera 9.25ではftpサイトで動作しません。
    Firefox 2.0.0.11ではftpサイトでも動作します。
javascript: void(function () {
	var exts = [
		'exe', 'msi', 'reg', 'zip', 'lzh', 'dmg', 'sit', 'hqx', 
		'pdf', 'txt', 'htm', 'html', 'css', 'js', 'swf', 
		'jpg', 'jpeg', 'eps', 'png', 'gif', 'tif', 'tiff', 'ico', 
	];
	var reExts = new RegExp('^.*\.(' + exts.join('|') + ')$', 'i');
	var links = document.getElementsByTagName('a');
	var urls = '';
	for (var i = 0; i < links.length; i++) {
		if (links[i].href && links[i].href.match(reExts)) {
			urls += links[i].href + '<br>\r\n'
		}
	}
	if (urls != '') {
		var docNew = window.open('', '_blank').document;
		docNew.open('text/html');
		docNew.write('<html><body>\n' + urls + '</body></html>');
		docNew.close();
	}
})()

ページの更新日時をポップアップ

javascript: void(function () {
	var title = '更新日時' + ((frames.length > 0) 
		? '\nフレームが使われています。正しい日時が得られていないかもしれません。' 
		: '');
	prompt(title, new Date(window.document.lastModified).toLocaleString());
})();

現在のページのレスポンスヘッダを表示

javascript: (function(uri) {
    var req = new XMLHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState === 4) {
            var regHeader = /^\s*([^:]+):\s*([\s\S]+)\s*$/;
            var result = '<table border="1">\n<tr><th>Response Header</th><th>Value</th></tr>\n';
            var headers = req.getAllResponseHeaders().replace(/\s+$/, '').split(/\r?\n/).sort();
            for (var i = 0, header; header = headers[i]; ++i) {
                if (regHeader.exec(header)) {
                    result += '<tr><td>' + RegExp.$1 + '</td><td>' + RegExp.$2 + '</td></tr>\n';
                }
            }
            result += '</table>\n';
            var docNew = window.open('', '_blank').document;
            docNew.open('text/html');
            docNew.write('<html><body>\n' + result + '</body></html>');
            docNew.close();
        }
    };
    req.open('GET', uri, false);
    req.send(null);
})(location.href);

選択した時刻文字列(EST, -05:00)をローカル時刻(JST, +09:00)に変換

javascript: (function () {
var SrcTimeZone = '-05:00';
var src = (window.getSelection().rangeCount) 
	? window.getSelection().getRangeAt(0).cloneContents().firstChild.nodeValue 
	: prompt('Time in ' + SrcTimeZone);
if (src) {
	var date = new Date(src + ' ' + SrcTimeZone);
	var year = padZero(date.getFullYear(), 4);
	var month = padZero(date.getMonth() + 1, 2);
	var day = padZero(date.getDate(), 2);
	var wday = new Array("", "", "", "", "", "", "")[date.getDay()];
	var hour = padZero(date.getHours(), 2);
	var min = padZero(date.getMinutes(), 2);
	var sec = padZero(date.getSeconds(), 2);
	var jst = year + '-' + month + '-' + day + ' (' + wday + ') ' + hour + ':' + min + ':' + sec;
	prompt(SrcTimeZone + ' -> JST(+09:00)\nSrc: ' + src, jst);
} else {
	alert("Invalid Range.");
}

function padZero(x, n) { /* n: 2 or 4 */
	return ('0000' + x).slice(-n);
}
})();

選択した文字列中の非ASCII文字をエスケープ

javascript: (function() {
    var src = window.getSelection().rangeCount ?
        window.getSelection().getRangeAt(0).cloneContents().firstChild.nodeValue :
        prompt('Paste string');
    var enc = '';
    for (var i = 0; i < src.length; ++i) {
        var code = src.charCodeAt(i);
        enc += 0x20 <= code && code < 0x7f ?
            src.charAt(i) :
            '&#x' + code.toString(16) + ';';
    }
    prompt('encoded', enc);
})();

ニコニコ動画のタイトルとIDを抽出

javascript:void(function(){
var title = (document.title.match(/(.+)\s\s[^\‐]+$/))[1];
title = title.replace( /([A-Za-z0-9_ ])/g, function(ch){
	return String.fromCharCode(ch.charCodeAt(0)-65248);
});
var vid = (location.href.match(/watch\/([^\?]+)/))[1];
prompt( 'Nico Video', '[[' + title + '>Nico:' + vid + ']]' );
})()

Ustream のチャンネル (PukiWiki用)

javascript:(function(){
prompt( 'UstCh', '[[UstCh:' + ( location.href.match( /\/channel\/(.+)/ ))[1] + ']]' );
})();

Ustream の録画済み番組へのリンク (PukiWiki 用)

javascript:void(function(){
var elm = document.getElementById( 'VideoTitle' );
location.href.match( /\/recorded\/(\d+(\/highlight\/\d+)?)/ );
var RecChannel = RegExp.$1;
prompt( 'Ustream Recorded', '[[' + elm.textContent + '>UstRec:' + RecChannel + ']]' );
})()

Ustream を全画面で見る

javascript:void(function(){
location.href = 'http://www.ustream.tv/flash/live/' + ustream.vars.channelId;
})()

http://srad.jp/ の記事のタイトルとIDを抽出

  • セクション名が付いている場合に対応。(2015/06/02)
  • ホスト変更に対応。(2015/05/12)
  • タイトルの並び順変更に対応。(2011/09/23)
  • システム変更に対応。(2011/08/31) <!---- headエレメントではなくdocument.titleを参照するようにした。(2010/04/28)-->
javascript: (function() {
	var title = document.title;
	title = title.replace(/\s+\|\s+スラド.*$/, "");
	var link = (location.href.match(/\/story\/(\d+\/\d+\/\d+\/\d+)/))[1];
	prompt('SlashDotJp: ' + link + '\n' + title, '[[' + title + '>SlashDotJp:' + link + ']]');
})();

Amazon の ASIN を抜き出す (PukiWiki 用)

javascript: (function() {
    var authers = [];
    var elmBooksTitle = document.getElementById('booksTitle');
    var links = (elmBooksTitle ? elmBooksTitle : document).getElementsByTagName('A');
    for (var i = 0, link; link = links[i]; ++i) {
        if (link.href.match(/field-author|_athr_/) || link.className.split(/\s/).indexOf('contributorNameID') >= 0) {
            var auther = link.textContent.replace(/\s/, "");
            if (!auther.match(/著者ページを見る$|検索結果/)) {
                authers.push(auther);
            }
        }
    }
    var ASIN = (location.href.match(/[\/\?](dp|ASIN|product|product-description|samples)[\/=]([0-9A-Z]{10})/))[2];
    prompt(authers.join("\n") + "\n" + ASIN, ((authers.length > 0) ? authers.join(",") + "/" : "") + "&amazon(" + ASIN + ");");
})();

twitter の発言者へのリンク (PukiWiki 用)

javascript: (function () {
	location.pathname.match(/^\/([^\/]+)(\/.*)?/);
	var dispName = RegExp.$1;
	var fullName = (!RegExp.$2) 
		? scanElements('h1', 'fullname') 
		: scanElements('strong', 'fullname');
	var name = fullName + ' (' + dispName + ')';
	prompt(name, '[[' + name + '>Twitter:' + dispName + ']]');

	function scanElements(tagName, className) {
		var ret = '';
		var elms = document.getElementsByTagName(tagName);
		for (var i = 0; i < elms.length; ++i) {
			if (elms[i].className.slice(0, className.length) == className) {
				ret = elms[i].innerText.replace(/^\s+|\s+$/g, '');
				break;
			}
		}
		return ret;
	}
})();

twitter の発言へのリンク

javascript:(function(){
var fullName = '';
var userLink = '';
var description = '';
var message = '';
var elms = document.getElementsByTagName( 'a' );
for( var i=0; i<elms.length; ++i ){
	if ( elms[i].className == 'tweet-user-block-screen-name user-profile-link' ){
		fullName = elms[i].title;
		userLink = elms[i].href;
		break;
	}
}
var elms = document.getElementsByTagName( 'div' );
for( var i=0; i<elms.length; ++i ){
	if ( elms[i].className == 'tweet-text tweet-text-large' ){
		description = elms[i].textContent || elms[i].innerText;
		break;
	}
}
var exLinks = [];
checkLink( /^(.*)\s*(#\w+)\s*$/, linkTwitHash );
checkLink( /^(.*)\s*(http\:\/\/[^\s]+)\s*$/, function(x){ return x; } );
checkLink( /^(.*)\s*(#\w+)\s*$/, linkTwitHash );
message += '[[' + fullName + '>' + userLink + ']]';
message += '「[[' + description + '>' + location.href + ']]';
for( var i=exLinks.length; --i>=0; ){
	message += ' [['+exLinks[i].key+'>'+exLinks[i].url+']]';
}
message += '';
prompt( 'twitLink', message );

function checkLink( regex, func ){
	while( description.match(regex) ){
		description = RegExp.$1;
		exLinks.push({ 
			'key': RegExp.$2, 
			'url': func(RegExp.$2), 
		});
	}
}

function linkTwitHash(x){
	return 'http://twitter.com/#!/search?q=' + encodeURIComponent(x);
}
})();

twitter の発言へのリンク (日時付き, PukiWiki用)

javascript:(function(){
var host = location.protocol + '//' + location.host;
location.href.match( /([^\/]+\/[^\/]+\/([^\/]+))$/ );
var TwitUrl = RegExp.$1;
var statusId = RegExp.$2;

var httpRequest = false;
if ( window.XMLHttpRequest ){
	/* Firefox, Opera など */
	httpRequest = new XMLHttpRequest();
	httpRequest.overrideMimeType('text/xml');
} else if( window.ActiveXObject ){
	/* IE */
	try {
		httpRequest = new ActiveXObject('Msxml.XMLHTTP');
	} catch(e){
		httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
	}
}

httpRequest.abort();
httpRequest.open( 'GET', host + '/statuses/show/' + statusId + '.json', true );
httpRequest.onreadystatechange = function(){
	if ( httpRequest.readyState == 4 && httpRequest.status == 200 ){
		var statusInfo = eval( '(' + httpRequest.responseText + ')' );
		/* alert( _dump( statusInfo ) ); */
		var date = new Date( statusInfo.created_at );
		prompt( 
			date.toLocaleString() + '\n' + statusInfo.text, 
			'[[' + date.toLocaleString() + '>Twitter:' + TwitUrl + ']]&br;' 
				+ statusInfo.text + '\n'
		);
	}
};
httpRequest.send( null );

function _dump( obj ){
	var ret = '';
	for( var p in obj ){
		if ( typeof(obj[p]) == 'object' ){
			ret += '\n' + p + ':\n';
			ret += _dump( obj[p] );
		} else {
			ret += p + ': ' + obj[p] + '\n';
		}
	}
	return ret;
}
})();

twitter の表示されているタイムラインを単純テキスト化

javascript: (function () {
var sTwHost = 'https://twitter.com';
var itrOriginalTweets = getIteratorByXpath('//div[starts-with(@class,"tweet original-tweet")]', document);
var sTweets = '';
var sNow = new Date().toLocaleString();
sTweets += sNow + '<br>\n';
try {
	var nodeTweet;
	while (nodeTweet = itrOriginalTweets.iterateNext()) {
		var sUserName = getStringByXpath('./div/div/a[starts-with(@class,"account-group")]/strong', nodeTweet);
		var isVerified = getStringByXpath('./div/div/a[starts-with(@class,"account-group")]/strong/span[starts-with(@class,"icon verified")]', nodeTweet);
		if ( isVerified ){
			sUserName = sUserName.replace( new RegExp( isVerified + '$' ), '' );
		}
		var sScreenName = getStringByXpath('./@data-screen-name', nodeTweet);
		/* var sDateTime = getStringByXpath( './div/div/small/a/@title', nodeTweet ); */
		var nDateTime = 1 * getStringByXpath('./div/div/small/a/span/@data-time', nodeTweet);
		if (nDateTime < 1151679600 * 1000) { /* 2006-07-01 以前だったら ms 単位に変換 */
			nDateTime *= 1000;
		}
		var sDateTime = new Date(nDateTime).toLocaleString();
		var sTweetId = getStringByXpath('./@data-tweet-id', nodeTweet);
		var sTweetUrl = sTwHost + '/' + sScreenName + '/status/' + sTweetId;
		sTweets += '----<br>\n';
		sTweets += '<a href="' + sTwHost + '/' + sScreenName + '" target="_blank">' + sUserName + '</a>\t';
		sTweets += ( isVerified ) ? '[' + isVerified + ']\t' : '';
		sTweets += '<a href="' + sTwHost + '/' + sScreenName + '" target="_blank">@' + sScreenName + '</a>\t';
		sTweets += sDateTime + '<br>\n';
		sTweets += '<a href="' + sTweetUrl + '" target="_blank">' + sTweetUrl + '</a><br>\n';
		sTweets += getStringByXpath('./div/p', nodeTweet).replace(/^\s+|\s+$/g, '').replace(/[<>]/g, function (c) {
			return '&#' + c.charCodeAt(0) + ';'
		}).replace(/[\r\n]+/g, '<br>\n') + '<br>\n';
		var itrLinks = getIteratorByXpath('./div/p/a', nodeTweet);
		if (itrLinks) {
			var nodeLink;
			while (nodeLink = itrLinks.iterateNext()) {
				var sLinks = getStringByXpath('./@data-ultimate-url', nodeLink) 
					|| getStringByXpath('./@data-expanded-url', nodeLink) || getStringByXpath('./@href', nodeLink);
				if (sLinks.slice(0, 1) == '/') {
					sLinks = sTwHost + sLinks;
				}
				sTweets += '<a href="' + sLinks + '" target="_blank">' + sLinks + '</a><br>\n';
			}
		}
	}
} catch (e) {
	alert('Error: ' + e);
}
var winOutput = window.open('', '_blank');
winOutput.document.open('text/html; charset=UTF-8');
winOutput.document.write('<html>\n<head><title>TwTextifier ' + sNow + '</title></head>\n<body>\n');
winOutput.document.write(sTweets);
winOutput.document.write('</body>\n</html>\n');
winOutput.document.close();

function getIteratorByXpath(xpath, context) {
	return document.evaluate(xpath, context, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
}

function getStringByXpath(xpath, context) {
	var sRet = "";
	var nodeTmp = document.evaluate('string(' + xpath + ')', context, null, XPathResult.STRING_TYPE, null);
	if (nodeTmp) {
		sRet = nodeTmp.stringValue;
	}
	return sRet;
}
})();

twitter の発言を twittaku で確認

javascript:(function(url){
if ( location.host == 'twitter.com' ){
	if ( url.match( /\/status\/(\d+)/ ) ){
		location = 'http://twittaku.info/view.php?id=' + RegExp.$1;
	} else if( url.match( /\/([^\/]+)$/ ) ){
		location = 'http://twittaku.info/searchtweet.php?type=name&word=' + RegExp.$1;
	}
}
})(location.href);

twitter.com から twilog.org へ転送

javascript: (function () {
	if (location.hostname == 'twitter.com' && location.pathname.match(/^\/([0-9a-zA-Z_]+)/)) {
		location = 'http://twilog.org/' + RegExp.$1;
	}
})();

togetter へのリンク (PukiWiki 用)

javascript:(function(){
if ( location.href.match( /^http:\/\/togetter.com\/(\w)([^\/]+)\/(.*)/ ) ){
	var type = 'Toget' + RegExp.$1.toUpperCase() + RegExp.$2;
	var id = RegExp.$3;
	var title = document.title.replace( /\s+-\s+Togetter$/, "" );
	prompt(
		type + ': ' + id + '\n' + title, 
		'[[' + title + '>' + type + ':' + id + ']]'
	);
}
})();

twemoji を現在のページに適用

javascript: (function() {
    var twemojiStyleElm = document.createElement('style');
    twemojiStyleElm.type = 'text/css';
    twemojiStyleElm.appendChild(document.createTextNode(
        'img.emoji { height: 1em; width: 1em; margin: 0.05em 0.1em; vertical-align: -0.1em; }'
    ));
    document.getElementsByTagName('head')[0].appendChild(twemojiStyleElm);
    var twemojiScriptElm = document.createElement('script');
    twemojiScriptElm.id = 'twemoji';
    twemojiScriptElm.type = 'text/javascript';
    twemojiScriptElm.src = '//twemoji.maxcdn.com/twemoji.min.js';
    twemojiScriptElm.addEventListener('load', (function(win) {
        return function() {
            twemoji.parse(win.document.body);
        };
    })(window), false);
    document.getElementsByTagName('body')[0].appendChild(twemojiScriptElm);
})();

WikiPediaへのリンク (PukiWiki 用)

javascript:(function(){
location.href.match(/(\w+)\.wikipedia\.org\/wiki\/(.*)/);
prompt('WikiPedia Link','[[WikiPedia.'+RegExp.$1+':'+decodeURI(RegExp.$2)+']]');
})();

CPANへのリンク (PukiWiki 用)

javascript:(function(){
location.href.match(/search\.cpan\.org\/dist\/(.*[^\/])\/?/);
prompt('CPAN Link','[[CPAN:'+RegExp.$1+']]');
})();

Pixivプロフィールへのリンク (PukiWiki 用)

javascript: (function() {
    if (location.hostname != 'www.pixiv.net') {
        return;
    }
    var userName = '';
    var h1s = document.getElementsByTagName('h1');
    for (var i = 0, h1; h1 = h1s[i]; ++i) {
        if (h1.className == 'user') {
            userName = h1.textContent;
            break;
        }
    }
    location.href.match(/member.php\?id=(\d+)/);
    prompt('Pixiv Member', '[[' + userName + '>PixivMember:' + RegExp.$1 + ']]');
})();

Pixivイラストへのリンク (PukiWiki 用)

javascript:(function(){
if ( location.hostname == 'www.pixiv.net' ){
	var Title = '';
	var IllustId = pixiv.context.illustId;
	var elmMetas = document.getElementsByTagName('meta');
	for(var i=0; i<elmMetas.length; ++i){
		if(elmMetas[i].outerHTML.match(/property="og:title"/)){
			Title = elmMetas[i].content;
		} else if(elmMetas[i].outerHTML.match(/property="og:url"/)){
			IllustId = (elmMetas[i].content.match(/illust_id=(\d+)/))[1];
		}
	}
	if ( !Title ){	/* 小説用 */
		Title = (document.title.match(/^「([^]+)」/))[1];
		IllustId = (location.href.match(/id=(\d+)$/))[1];
	}
	var UserId = pixiv.context.userId;
	var UserName = '';
	var elmAnchors = document.getElementsByTagName('a');
	for(var i=0; i<elmAnchors.length; ++i){
		if(elmAnchors[i].href.match(/member.php\?id=(\d+)/)){
			UserId = RegExp.$1;
			UserName = elmAnchors[i].innerText.replace(/^\s+|\s+$/g, '');
			if ( UserName != 'プロフィール' && UserName != '' ){
				break;
			}
		}
	}
	prompt( 
		'Pixiv Member & Illust', 
		'[[' + UserName + '>PixivMember:' + UserId + ']]' 
		+ ' / [[' + Title + '>PixivIllust:' + IllustId + ']] ' 
	);
}
})();

GitHub リポジトリのリンク (PukiWiki 用)

javascript: (function() {
	if (location.host != 'github.com') {
		return;
	}
	location.pathname.match(/^\/([^\/]+\/[^\/]+)/);
	var key = RegExp.$1;
	prompt(key, '[[GitHub:' + key + ']]');
})();

Stackoverflow へのリンク (PukiWiki 用)

javascript: (function(title, uri) {
  if (!uri.match(/^https?:\/\/(?:(\w+)\.)?stackoverflow.com\/questions\/(\d+)\//)) {
    return;
  }
  var alias = 'Stackoverflow' + (RegExp.$1 != "" ? '.' + RegExp.$1 : '') + ':' + RegExp.$2;
  prompt(title + '\n' + alias, '[[' + title + '>' + alias + ']]');
})(document.title, location.href);

IETF RFC へのリンク (PukiWiki 用)

javascript: void(function() {
  if (location.host != 'www.ietf.org' && location.host != 'tools.ietf.org') {
    return;
  }
  var title = document.title;
  location.pathname.match(/\/(rfc|html)\/rfc(\d+)/);
  var id = RegExp.$2;
  prompt(title + '\n' + id, '[[' + title + '>RFC:' + id + ']]');
})();

テーブル内の特定のセルの内容をポップアップ

PukiWiki エイリアス

  • body の最初の h2 タグをエイリアス名として抽出
    javascript: (function () {
    var pageTitle = getStringByXpath('//div[@id="body"]/h2[1]', document);
    var pageName = getStringByXpath('//div[@id="header"]/h1[@class="title"]/a', document);
    prompt(pageTitle + '\n' + pageName, '[[' + pageTitle + '>' + pageName + ']]');
    
    function getStringByXpath(xpath, context) {
    	var sRet = "";
    	var nodeTmp = document.evaluate('string(' + xpath + ')', context, null, XPathResult.STRING_TYPE, null);
    	if (nodeTmp) {
    		sRet = nodeTmp.stringValue;
    	}
    	return sRet;
    }
    })();