@@ -19,9 +19,10 @@
function getAsin(str) {
var ret = "";
- if ( (str.search(/[^0-9A-Z]([B0-9][0-9A-Z]{9})([^0-9A-Z]|$)/) != -1) &&
- (isAsin(RegExp.$1)) ) {
- ret = RegExp.$1;
+ if ( (!!str) &&
+ (str.search(/([^0-9A-Z]|^)([B0-9][0-9A-Z]{9})([^0-9A-Z]|$)/) != -1) &&
+ (isAsin(RegExp.$2)) ) {
+ ret = RegExp.$2;
}
return ret;
}
@@ -93,62 +94,62 @@
function r() { b.style.visibility = "hidden";}
function j() { b.style.visibility = "visible";}
if (b) {
- if (b.style.visibility == "visible") {
- r();
- } else {
- j();
- }
- return;
+ if (b.style.visibility == "visible") {
+ r();
+ } else {
+ j();
+ }
+ return;
}
if (!p) {
- m = m.replace(/.ws_cmbmc/g, "#" + h);
- p = s.createElement("style");
- p.type = "text/css";
- p.id = d;
- if (p.styleSheet) {
- p.styleSheet.cssText = m; /* for IE */
- } else {
- p.appendChild(s.createTextNode(m));
- }
- s.getElementsByTagName("head")[0].appendChild(p);
+ m = m.replace(/.ws_cmbmc/g, "#" + h);
+ p = s.createElement("style");
+ p.type = "text/css";
+ p.id = d;
+ if (p.styleSheet) {
+ p.styleSheet.cssText = m; /* for IE */
+ } else {
+ p.appendChild(s.createTextNode(m));
+ }
+ s.getElementsByTagName("head")[0].appendChild(p);
}
b = s.createElement("div");
b.setAttribute("id", h);
b.className = "ws_cmbmc";
for (o = 0; o < n.length; o++) {
- e = s.createElement("a");
- e.appendChild(s.createTextNode(n[o].title));
- e.setAttribute("href", n[o].url.split("%s").join(t)); /* replace(/%s/g, t)); */
- e.onclick = (function (i) {
- if (q) {
- r();
- }
- });
- b.appendChild(e);
+ e = s.createElement("a");
+ e.appendChild(s.createTextNode(n[o].title));
+ e.setAttribute("href", n[o].url.split("%s").join(t)); /* replace(/%s/g, t)); */
+ e.onclick = (function (i) {
+ if (q) {
+ r();
+ }
+ });
+ b.appendChild(e);
}
s.getElementsByTagName("body")[0].appendChild(b);
if (a.hasOwnProperty(g)) {
- for (k in a[g]) {
- b.style[k] = a[g][k] + "px";
- }
+ for (k in a[g]) {
+ b.style[k] = a[g][k] + "px";
+ }
} else {
- if (g == "c") {
- b.style.left = Math.round(((window.innerWidth ? window.innerWidth : s.body.clientWidth ) - b.offsetWidth ) / 2) + "px";
- b.style.top = Math.round(((window.innerHeight ? window.innerHeight : s.body.clientHeight) - b.offsetHeight) / 2) + "px";
- }
+ if (g == "c") {
+ b.style.left = Math.round(((window.innerWidth ? window.innerWidth : s.body.clientWidth ) - b.offsetWidth ) / 2) + "px";
+ b.style.top = Math.round(((window.innerHeight ? window.innerHeight : s.body.clientHeight) - b.offsetHeight) / 2) + "px";
+ }
}
if (c) {
- s.onclick = (function () {
- r();
- if (typeof l == "function") {
- l();
- }
- });
- b.onclick = (function (i) {
- if (i){
- i.stopPropagation();
- }
- });
+ s.onclick = (function () {
+ r();
+ if (typeof l == "function") {
+ l();
+ }
+ });
+ b.onclick = (function (i) {
+ if (i){
+ i.stopPropagation();
+ }
+ });
}
j();
}
@@ -240,16 +241,18 @@
}
];
var SEARCH_URL = "http://www.amazon.co.jp/exec/obidos/external-search/?keyword=%s&mode=books-jp&tag=kooniesb-22";
- var REPLACE_WORD = getAsin(location.href);
- if (!!REPLACE_WORD) {
- UrlCombiner(URLS, REPLACE_WORD, MENU_POS, CLOSE_AFTER_CLICK, CLOSE_ELSEWHERE, BOOKMARKLET_ID);
- } else {
- var word = getSelString();
- if (!word) {
- word = prompt("検索キーワードを入力 (例.1Q84)", word);
- }
- if (word) {
- location.href = SEARCH_URL.replace("%s", encodeURIComponent(word));
- }
+ var asin = getAsin(location.href);
+ if (!asin) {
+ var word = getSelString() ||
+ prompt("表示中のサイトからはASINコードは取得できませんでした。以下のどちらかを入力してください。\n" +
+ "→ 検索キーワード(例.1Q84)\n" +
+ "→ ASIN10桁コード(例.4103534222)", "4103534222");
+ asin = getAsin(word);
+ }
+ if (asin) {
+ UrlCombiner(URLS, asin, MENU_POS, CLOSE_AFTER_CLICK, CLOSE_ELSEWHERE, BOOKMARKLET_ID);
+ } else if (word) {
+ location.href = SEARCH_URL.replace("%s", encodeURIComponent(word));
}
+
})();
/*
* @title HON39(本索)
* @description 本を買って借りて読みまくるブックマークレット!
* @description 実行したサイトからISBN/ASINコードが取得できれば色々なサイトへのリンクを表示
*/
(function () {
function isAsin(asin) {
/* http://ja.wikipedia.org/wiki/ISBN#.E3.83.81.E3.82.A7.E3.83.83.E3.82.AF.E3.83.87.E3.82.B8.E3.83.83.E3.83.88 */
/* http://www.amazon.co.jp/gp/help/customer/display.html?nodeId=747416 */
var i, j, sum;
if (asin.charAt(0) == "B") {return true;} /* ASIN */
for (i=0, j=10, sum=0; j>1; i++, j--) {
sum += j * asin.charAt(i);
}
return (asin.charAt(i).replace("X", 10) == (11-(sum%11))%11); /* ISBN */
}
function getAsin(str) {
var ret = "";
if ( (!!str) &&
(str.search(/([^0-9A-Z]|^)([B0-9][0-9A-Z]{9})([^0-9A-Z]|$)/) != -1) &&
(isAsin(RegExp.$2)) ) {
ret = RegExp.$2;
}
return ret;
}
function UrlCombiner(n, t, g, q, c, f) {
/* Based on Bookmarklet Combiner */
/* http://w-shadow.com/bookmarklet-combiner/ */
var s = document,
l = s.onclick,
h = "ws_cmbm-" + f,
b = s.getElementById(h),
d = "ws_cmbms-" + f,
p = s.getElementById(d),
e = null,
o,
a = {
tl: {left: 10, top: 10},
tr: {right: 10, top: 10},
bl: {left: 10, bottom: 10},
br: {right: 10, bottom: 10}
},
k,
m = [ ".ws_cmbmc{",
"position:fixed!important;",
"position:absolute;",
"z-index:1001;",
"width:350px;",
"display:block;",
"visibility:hidden;",
"border:1px solid #b0b0b0;",
"background:#0d5da8;",
"padding:3px 0 3px 3px;",
"text-align:left;",
"border-radius:7px;",
"-moz-border-radius:7px;",
"-webkit-border-radius:7px;",
"box-shadow:4px 4px 6px #777;",
"-moz-box-shadow:4px 4px 6px #777;",
"-webkit-box-shadow:4px 4px 6px #777;",
"}",
".ws_cmbmc a{",
"display:block;",
"float:left;",
"margin:0;",
"width:341px;",
"border:none;",
"padding:5px 0 5px 6px;",
"background:#0d5da8;",
"color:white;",
"text-decoration:none;",
"font:normal normal normal 12px Verdana,sans-serif;",
"letter-spacing:normal;",
"word-spacing:normal;",
"}",
".ws_cmbmc a:hover{",
"background:#fff;",
"color:#0d5da8;",
"border:none;",
"text-decoration:none;",
"font:normal normal normal 12px Verdana,sans-serif;",
"letter-spacing:normal;",
"word-spacing:normal;",
"border-radius:3px;",
"-moz-border-radius:3px;",
"-webkit-border-radius:3px;",
"}"
].join("");
function r() { b.style.visibility = "hidden";}
function j() { b.style.visibility = "visible";}
if (b) {
if (b.style.visibility == "visible") {
r();
} else {
j();
}
return;
}
if (!p) {
m = m.replace(/.ws_cmbmc/g, "#" + h);
p = s.createElement("style");
p.type = "text/css";
p.id = d;
if (p.styleSheet) {
p.styleSheet.cssText = m; /* for IE */
} else {
p.appendChild(s.createTextNode(m));
}
s.getElementsByTagName("head")[0].appendChild(p);
}
b = s.createElement("div");
b.setAttribute("id", h);
b.className = "ws_cmbmc";
for (o = 0; o < n.length; o++) {
e = s.createElement("a");
e.appendChild(s.createTextNode(n[o].title));
e.setAttribute("href", n[o].url.split("%s").join(t)); /* replace(/%s/g, t)); */
e.onclick = (function (i) {
if (q) {
r();
}
});
b.appendChild(e);
}
s.getElementsByTagName("body")[0].appendChild(b);
if (a.hasOwnProperty(g)) {
for (k in a[g]) {
b.style[k] = a[g][k] + "px";
}
} else {
if (g == "c") {
b.style.left = Math.round(((window.innerWidth ? window.innerWidth : s.body.clientWidth ) - b.offsetWidth ) / 2) + "px";
b.style.top = Math.round(((window.innerHeight ? window.innerHeight : s.body.clientHeight) - b.offsetHeight) / 2) + "px";
}
}
if (c) {
s.onclick = (function () {
r();
if (typeof l == "function") {
l();
}
});
b.onclick = (function (i) {
if (i){
i.stopPropagation();
}
});
}
j();
}
function getSelString() {
var i, str = "";
try {
str = (!!window.getSelection) ? window.getSelection().toString() : document.selection.createRange().text;
if (!str) {
if (frames.length) {
for (i=0; i<frames.length; i++) {
if ( ((!!frames[i].getSelection) || (!!frames[i].document)) &&
(str = (!!frames[i].getSelection) ? frames[i].getSelection().toString() : frames[i].document.selection.createRange().text)
) {break;}
}
}
}
} catch (e) {}
return str;
}
var MENU_POS = "tr"; /* tl,tr,bl,br,c */
var CLOSE_AFTER_CLICK = false;
var CLOSE_ELSEWHERE = true;
var BOOKMARKLET_ID = "asin_bookmarklet";
var URLS = [{
title: "はてなブックマーク",
url: "http://b.hatena.ne.jp/entry/www.amazon.co.jp/gp/product/%s"
},{
title: "はてなダイアリー",
url: "http://d.hatena.ne.jp/asin/%s"
},{
title: "InBook.jp (セリフ引用)",
url: "http://inbook.jp/inbook/ASIN=%s"
},{
title: "読書メーター",
url: "http://book.akahoshitakuya.com/b/%s"
},{
title: "読んだ4!",
url: "http://yonda4.com/asin/%s"
},{
title: "Stack Stock Books",
url: "http://stack.nayutaya.jp/book/%s"
},{
title: "Webcat Plus",
url: "http://webcatplus.nii.ac.jp/webcatplus/details/book/isbn/%s.html"
},{
title: "ブクログ (5段階評価)",
url: "http://booklog.jp/asin/%s"
},{
title: "crossreview (10段階評価、本以外も対応)",
url: "http://crossreview.jp/product/%s"
},{
title: "メディアマーカー (5段階評価、本以外も対応)",
url: "http://mediamarker.net/media/0/?asin=%s"
},{
title: "Amazon.co.jp (5段階評価、本以外も対応)",
url: "http://www.amazon.co.jp/product-reviews/%s?tag=kooniesb-22"
},{
title: "Amazon.co.jp (ショッピングカートに入れる)",
url: "javascript:document.write('<form name=cart_form method=%22post%22 action=%22http://www.amazon.co.jp/gp/aws/cart/add.html%22> <input type=%22hidden%22 name=%22ASIN.1%22 value=%22%s%22> <input type=%22hidden%22 name=%22Quantity.1%22 value=%221%22> <input type=%22hidden%22 name=%22AssociateTag%22 value=%22kooniesb-22%22> <input type=%22hidden%22 name=%22SubscriptionId%22 value=%22your_subscription_id%22> <input type=%22image%22 name=%22submit.add-to-cart%22 src=%22http://rcm-images.amazon.com/images/G/09/extranet/associates/buttons/remote-buy-jp1.gif%22 alt=%22amazon.co.jp で買う%22> </form>');document.cart_form.submit();"
},{
title: "楽天ブックス",
url: "http://search.books.rakuten.co.jp/bksearch/nm?sitem=%s"
},{
title: "ビーケーワン",
url: "http://www.bk1.jp/isbn/%s"
},{
title: "TSUTAYA",
url: "http://shop.tsutaya.co.jp/search_result.html?searchType=2&ecCategory=05&isbnJan=%s"
},{
title: "Yahoo!ブックス",
url: "http://books.yahoo.co.jp/search?mcd=&s=-5&b=1&ty=0&so=1&k=0&ismc=1&x=0&y=0&isbn=%s"
},{
title: "丸善とジュンク堂書店 (在庫ありの店舗チェック)",
url: "http://www.junkudo.co.jp/find2.jsp?isbn=%s"
},{
title: "紀伊国屋 (たまに新聞書評)",
url: "http://bookweb.kinokuniya.co.jp/htm/%s.html"
},{
title: "Bookget (本・中古本の一括検索)",
url: "http://bookget.net/pack?asin=%s"
},{
title: "カーリル (図書館検索)",
url: "http://calil.jp/book/%s"
},{
title: "Google ブックス (プレビュー)",
url: "http://www.google.co.jp/search?tbm=bks&tbo=1&q=isbn:%s"
}
];
var SEARCH_URL = "http://www.amazon.co.jp/exec/obidos/external-search/?keyword=%s&mode=books-jp&tag=kooniesb-22";
var asin = getAsin(location.href);
if (!asin) {
var word = getSelString() ||
prompt("表示中のサイトからはASINコードは取得できませんでした。以下のどちらかを入力してください。\n" +
"→ 検索キーワード(例.1Q84)\n" +
"→ ASIN10桁コード(例.4103534222)", "4103534222");
asin = getAsin(word);
}
if (asin) {
UrlCombiner(URLS, asin, MENU_POS, CLOSE_AFTER_CLICK, CLOSE_ELSEWHERE, BOOKMARKLET_ID);
} else if (word) {
location.href = SEARCH_URL.replace("%s", encodeURIComponent(word));
}
})();