Skip to content

Instantly share code, notes, and snippets.

@moyashi
Created November 7, 2011 22:07
Show Gist options
  • Save moyashi/1346360 to your computer and use it in GitHub Desktop.
Save moyashi/1346360 to your computer and use it in GitHub Desktop.
tracking_id = "hitoriblog0c-22";
pf = "http://www.amazon.co.jp/exec/obidos/ASIN/";
d = document;
u = d.location.href;
re = new RegExp("^http://www.amazon.co.jp/gp/aw/d/([0-9A-Z]{10})");
res = u.match(re);
if (res) {
asin = res[1];
afurl = pf + asin + "/" + tracking_id + "/ref=nosim/";
tmp = d.evaluate('//div[@class="dpProductTitle"]', d, null, 7, null).snapshotItem(0);
if (tmp) {
n = tmp.textContent;
}
tmp = d.evaluate('//div[@class="title"]', d, null, 7, null).snapshotItem(0);
if (tmp) {
n = tmp.textContent;
}
n = n.replace(/\s+$/, "");
n = n.replace(/^\s+/, "");
b = "";
tmp = d.evaluate('//div[@class="dpByInfoLine"]', d, null, 7, null).snapshotItem(0);
if (tmp) {
b = tmp.textContent;
}
tmp = d.evaluate('id("right")/a[1]', d, null, 7, null).snapshotItem(0);
if (tmp) {
b = tmp.textContent;
}
b = b.replace(/\s+$/, "");
b = b.replace(/^\s+/, "");
mes = encodeURIComponent("\"" + n + " / " + b + "\" " + afurl);
window.location="twitter://post?message=" + mes;
} else {
alert("想定しないURL/異常終了します");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment