リンクページ
はてぶに代表されるソーシャルブックマークサービス(SBM)は誰かが能動的にブックマークしたものが蓄積されている。Blogとか読んでるとはてぶにブックマークした人数が表示されていたり。
Google ってURLの頭に link: をつけるとそのURLにリンクしているページの一覧が取れるわけで。SBMではないけど、何かそんなの分かったら面白いかなーとおもって、「今見ているページにリンクしている(Google上での)ページ数」を出す GreaseMonkey スクリプトを書いてみた。
やってみた感想は、というと案外面白くなかった(ぉぃ
恐らく実際にリンクされてる数よりかなり少なく出てくるのよね。っつーか、Google はあんまりリンクの解析やってないのかな。でもPageRankに必要だしやってるはずだな。検索結果への反映がされないだけかな。
ま、たまにBlogやニュースサイトの個別の記事に対するリンクを追いかけたら面白いこともあるんだけど。
つーことでいい加減Script。Google Search API とか使うと面倒なので、ページとってきて正規表現。日本語が入ってることもあって、ゴミが入っちゃうことも多いんだけど、まぁいいや。
// ==UserScript==
// @name Google Link Checker
// @namespace http://hogehoge.com/
// @include http://*
// @include https://*
// @exclude http://10.*
// @exclude http://172.16.*
// @exclude http://172.17.*
// @exclude http://172.18.*
// @exclude http://172.19.*
// @exclude http://172.20.*
// @exclude http://172.21.*
// @exclude http://172.22.*
// @exclude http://172.23.*
// @exclude http://172.24.*
// @exclude http://172.25.*
// @exclude http://172.26.*
// @exclude http://172.27.*
// @exclude http://172.28.*
// @exclude http://172.29.*
// @exclude http://172.30.*
// @exclude http://172.31.*
// @exclude http://192.168.*
// @exclude http://www.google.*/search*
// ==/UserScript==
var target = 'http://www.google.co.jp/search?hl=ja&q=link%3A' + encodeURIComponent(location.href);
GM_xmlhttpRequest({
method: 'GET',
url: target,
onload: function(r){
res = r.responseText;
init();
},
});
function init() {
if (res.match(/検索結果(.*)件中/) != -1) {
var cnt = trim(RegExp.$1);
if (cnt != '.' && cnt != '') {
var d = document.createElement('div');
d.setAttribute('id', 'google_link_checker');
d.setAttribute("style", "position: fixed; bottom:0px; right:0px;");
d.innerHTML = '<a href="'+target+'">'+cnt+'件</a>';
document.body.appendChild(d);
GM_addStyle('#google_link_checker{background-color: #eeffee; color: #88ff88; font-weight: bold; font-size: 12px;font-family: "Helvetica", "Arial", sans-serif; width: 75px; height: 16px; border: solid 1px #88ff88; text-align: right; padding 0px; margin: 0px;} #google_link_checker a{text-decoration: none; color: #88ff88;}');
}
}
}
function trim(s)
{
var l=0; var r=s.length -1;
while(l < s.length && s[l] == ' ')
{ l++; }
while(r > l && s[r] == ' ')
{ r-=1; }
return s.substring(l, r+1);
}
| 固定リンク
« 恥の文化 | トップページ | マニアックニュース »
「てっく」カテゴリの記事
- Tampermonkey と jQuery(2015.04.17)
- Yosemite遠隔Update(2015.03.13)
- Google Calendar API v3(2014.11.19)
- IRKit(2014.07.16)
- WiTV(2014.05.19)
コメント