QuotaDetailからデータ取得

現在のQuotaの状態を、取得してグラフにしたい。
手っ取り早く、Bookmarkletを作ってみた。
Firefox限定

QuotaDetail[Key]

CPU Timeなどの値を取得する。
表を作成する際に使用する。
javascript:(function(){var%20XPATH_KEY%20%3D%20%22/html/body/div/div%5B3%5D/div%5B2%5D/div/div/table/tbody/tr/td%5B1%5D%22%3Bvar%20result%20%3D%20%22date%5Cn%22%3Bvar%20iterator%20%3D%20document.evaluate%28XPATH_KEY%2C%20document%2C%20null%2C%20XPathResult.ANY_TYPE%2Cnull%29%3Bwhile%28elmKey%20%3D%20iterator.iterateNext%28%29%29%20%7B%20%20result%20+%3D%20elmKey.innerHTML.trim%28%29%20+%20%22%5Cn%22%3B%7Dalert%28result%29%3B})();

var XPATH_KEY = "/html/body/div/div[3]/div[2]/div/div/table/tbody/tr/td[1]";
var result = "date\n";
var iterator = document.evaluate(XPATH_KEY, document, null, XPathResult.ANY_TYPE,null);

while(elmKey = iterator.iterateNext()) {
  result += elmKey.innerHTML.trim() + "\n";
}alert(result);

QuotaDetail[Value]

実際の値(数値)を取得する。
1行目は、取得した日時。
javascript:(function(){var%20XPATH_KEY%20%3D%20%22/html/body/div/div%5B3%5D/div%5B2%5D/div/div/table/tbody/tr/td%5B4%5D/span%22%3Bvar%20now%20%3D%20new%20Date%28%29%3Bvar%20result%20%3D%20now.getFullYear%28%29%20+%20%22/%22%20+%20%28now.getMonth%28%29+1%29%20+%20%22/%22%20+%20now.getDate%28%29%20+%20%22%20%22%20+%20now.getHours%28%29%20+%20%22%3A%22%20+%20now.getMinutes%28%29%20+%20%22%3A%22%20+%20now.getSeconds%28%29%3Bvar%20iterator%20%3D%20document.evaluate%28XPATH_KEY%2C%20document%2C%20null%2C%20XPathResult.ANY_TYPE%2Cnull%29%3Bwhile%28elmKey%20%3D%20iterator.iterateNext%28%29%29%20%7B%20%20result%20+%3D%20elmKey.innerHTML.trim%28%29.split%28%22of%22%29%5B0%5D.trim%28%29%20+%20%22%5Cn%22%3B%7Dalert%28result%29%3B})();

var XPATH_KEY = "/html/body/div/div[3]/div[2]/div/div/table/tbody/tr/td[4]/span";
var now = new Date();
var result = now.getFullYear() + "/" + (now.getMonth()+1) + "/" + now.getDate() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds() + "\n";
var iterator = document.evaluate(XPATH_KEY, document, null, XPathResult.ANY_TYPE,null);

while(elmKey = iterator.iterateNext()) {
  result += elmKey.innerHTML.trim().split("of")[0].trim() + "\n";
}

alert(result);

QuotaDetail[Percent]

各Quotaのパーセントを取得する。
1行目は同じく日時。
javascript:(function(){var%20XPATH_KEY%20%3D%20%22/html/body/div/div%5B3%5D/div%5B2%5D/div/div/table/tbody/tr/td%5B4%5D/span%22%3Bvar%20now%20%3D%20new%20Date%28%29%3Bvar%20result%20%3D%20now.getFullYear%28%29%20+%20%22/%22%20+%20%28now.getMonth%28%29+1%29%20+%20%22/%22%20+%20now.getDate%28%29%20+%20%22%20%22%20+%20now.getHours%28%29%20+%20%22%3A%22%20+%20now.getMinutes%28%29%20+%20%22%3A%22%20+%20now.getSeconds%28%29%20+%20%22%5Cn%22%3Bvar%20iterator%20%3D%20document.evaluate%28XPATH_KEY%2C%20document%2C%20null%2C%20XPathResult.ANY_TYPE%2Cnull%29%3Bwhile%28elmKey%20%3D%20iterator.iterateNext%28%29%29%20%7B%20%20var%20data%20%3D%20elmKey.innerHTML.trim%28%29.split%28%22of%22%29%5B0%5D.trim%28%29%3B%20%20var%20max%20%3D%20elmKey.innerHTML.trim%28%29.split%28%22of%22%29%5B1%5D.trim%28%29.split%28%22%5Cn%22%29%5B0%5D%3B%20%20result%20+%3D%20100*data/max%20+%20%22%5Cn%22%3B%7Dalert%28result%29%3B})();

var XPATH_KEY = "/html/body/div/div[3]/div[2]/div/div/table/tbody/tr/td[4]/span";
var now = new Date();
var result = now.getFullYear() + "/" + (now.getMonth()+1) + "/" + now.getDate() + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds() + "\n";
var iterator = document.evaluate(XPATH_KEY, document, null, XPathResult.ANY_TYPE,null);

while(elmKey = iterator.iterateNext()) {
  var data = elmKey.innerHTML.trim().split("of")[0].trim();
  var max = elmKey.innerHTML.trim().split("of")[1].trim().split("\n")[0];
  result += 100*data/max + "\n";
}

alert(result);

QuotaDetail[All]

上記3つを続けて実行。
javascript:(function(){var%20XPATH_KEY%20%3D%20%22/html/body/div/div%5B3%5D/div%5B2%5D/div/div/table/tbody/tr/td%5B1%5D%22%3Bvar%20result%20%3D%20%22date%5Cn%22%3Bvar%20iterator%20%3D%20document.evaluate%28XPATH_KEY%2C%20document%2C%20null%2C%20XPathResult.ANY_TYPE%2Cnull%29%3Bwhile%28elmKey%20%3D%20iterator.iterateNext%28%29%29%20%7B%20%20result%20+%3D%20elmKey.innerHTML.trim%28%29%20+%20%22%5Cn%22%3B%7Dalert%28result%29%3Bvar%20XPATH_KEY%20%3D%20%22/html/body/div/div%5B3%5D/div%5B2%5D/div/div/table/tbody/tr/td%5B4%5D/span%22%3Bvar%20now%20%3D%20new%20Date%28%29%3Bvar%20result%20%3D%20now.getFullYear%28%29%20+%20%22/%22%20+%20%28now.getMonth%28%29+1%29%20+%20%22/%22%20+%20now.getDate%28%29%20+%20%22%20%22%20+%20now.getHours%28%29%20+%20%22%3A%22%20+%20now.getMinutes%28%29%20+%20%22%3A%22%20+%20now.getSeconds%28%29%20+%20%22%5Cn%22%3Bvar%20iterator%20%3D%20document.evaluate%28XPATH_KEY%2C%20document%2C%20null%2C%20XPathResult.ANY_TYPE%2Cnull%29%3Bwhile%28elmKey%20%3D%20iterator.iterateNext%28%29%29%20%7B%20%20result%20+%3D%20elmKey.innerHTML.trim%28%29.split%28%22of%22%29%5B0%5D.trim%28%29%20+%20%22%5Cn%22%3B%7Dalert%28result%29%3Bvar%20XPATH_KEY%20%3D%20%22/html/body/div/div%5B3%5D/div%5B2%5D/div/div/table/tbody/tr/td%5B4%5D/span%22%3Bvar%20now%20%3D%20new%20Date%28%29%3Bvar%20result%20%3D%20now.getFullYear%28%29%20+%20%22/%22%20+%20%28now.getMonth%28%29+1%29%20+%20%22/%22%20+%20now.getDate%28%29%20+%20%22%20%22%20+%20now.getHours%28%29%20+%20%22%3A%22%20+%20now.getMinutes%28%29%20+%20%22%3A%22%20+%20now.getSeconds%28%29%20+%20%22%5Cn%22%3Bvar%20iterator%20%3D%20document.evaluate%28XPATH_KEY%2C%20document%2C%20null%2C%20XPathResult.ANY_TYPE%2Cnull%29%3Bwhile%28elmKey%20%3D%20iterator.iterateNext%28%29%29%20%7B%20%20var%20data%20%3D%20elmKey.innerHTML.trim%28%29.split%28%22of%22%29%5B0%5D.trim%28%29%3B%20%20var%20max%20%3D%20elmKey.innerHTML.trim%28%29.split%28%22of%22%29%5B1%5D.trim%28%29.split%28%22%5Cn%22%29%5B0%5D%3B%20%20result%20+%3D%20100*data/max%20+%20%22%5Cn%22%3B%7Dalert%28result%29%3B})();

で、今思ったのは
Excelにするなら列と行を逆にすればよかった。。
あとでやろー。