Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save themeofn/960720 to your computer and use it in GitHub Desktop.
Save themeofn/960720 to your computer and use it in GitHub Desktop.
Kakaku.com Media Price per GB
// ==UserScript==
// @name Kakaku.com Media Price per GB
// @description 価格.comでDVD, Blu-rayメディアのGBあたりの単価を表示
// @namespace http://d.hatena.ne.jp/n2s/20110507/kakakucom
// @include http://kakaku.com/specsearch/0710/
// @include http://kakaku.com/specsearch/0711/
// ==/UserScript==
(function(){
// 複数の容量があるメディアについて使用
var getSize = function(tds){
var s = tds[9].textContent.match(/[\d.]+/);
return(s && s[0]);
};
var msize = {
"DVD-R": 4.7,
"DVD-R DL": 8.5,
"DVD-RW": 4.7,
"DVD+R": 4.7,
"DVD+R DL": 8.5,
"DVD+RW": 4.7,
"RAM": getSize,
"RAM TYPE4": getSize,
"RAM TYPE2": getSize,
"HD DVD-R": getSize,
"BD-R": 25,
"BD-RE": 25,
"BD-R DL": 50,
"BD-RE DL": 50,
"BD-R XL": 100
};
var i, tr, tds, mt, td_pp, pp, ms, div;
var trs = document.querySelectorAll("#spec_result table table tr");
for(i = 0; tr = trs[i]; ++i){
if(tr.className.match(/^bgColor/)){ continue; }
tds = tr.querySelectorAll("td");
// メディアタイプ→容量
ms = msize[tds[8].textContent];
if(typeof(ms) === "function"){
ms = ms(tds);
}
// 1枚あたり
td_pp = tds[13];
pp = td_pp.textContent.match(/[\d.,]+/);
if(!(ms && pp)){ continue; }
div = document.createElement("div");
div.appendChild(document.createTextNode("\\" + (pp[0].replace(/,/g,"")/ms).toPrecision(3) + "/GB"));
td_pp.appendChild(div);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment