Amazon img + asin
by
noromanba
2013-07-26 [2013/07/26 07:19:46]
prompt minified Amazon link with img; LGTM for Hatena Space
@@ -2,18 +2,36 @@
* @title Amazon img + asin
* @description prompt minified Amazon link with img; LGTM for Hatena Space
* @include http://www.amazon.tld/*
- * @license MIT License http://nrm.mit-license.org/2013
+ * @license MIT License http://nrm.mit-license.org/2013
* @require
*/
+// pair-script
+// http://let.hatelabo.jp/noromanba/let/gYC-y8DN9c28Rw
+
// c.f. http://space.hatena.ne.jp/~/14217943783080751724#14217943783080751726+45
+// http://space.hatena.ne.jp/~/14217943783080751724/14290001378108728700/3
(function () {
var tld, asin;
- if (!(tld = (/^www\.amazon\.([a-z\.]+)/.exec(location.hostname) || [])[1]) || // world
- !(asin = (document.querySelector('#ASIN') || {}).value)) {
+ //*
+ if (!(tld = location.hostname.match(/^www\.amazon\.([a-z\.]+)/) || [])[1]) ||
+ !(asin = (location.pathname.match(/dp\/(\w+)/) || [])[1])) {
return;
}
- var img = (document.querySelector('#prodImageContainer img, #main-image, #kib-ma-container-0 img') || {}).src;
+ /*/
+ var meta = (location.href.match(/^https?:\/\/www\.amazon\.([a-z\.]+).*\/dp\/(\w+)/) || []).slice(1);
+ if (meta.length < 2) return;
+
+ tld = meta[0], asin = meta[1];
+ //*/
+
+ var query = {
+ 'normal': '#prodImageContainer img',
+ 'other' : '#main-image',
+ 'kindle': '#kib-ma-container-0 img'
+ };
+ query = Object.keys(query).map(function (k) { return query[k]; });
+ var img = (document.querySelector(query) || {}).src;
- prompt('copy me', (img + '\n' || '') + 'http://www.amazon.' + tld + '/dp/' + asin);
-})();
+ prompt('copy me', (img + ' \n' || '') + 'http://www.amazon.' + tld + '/dp/' + asin);
+})();
/*
* @title Amazon img + asin
* @description prompt minified Amazon link with img; LGTM for Hatena Space
* @include http://www.amazon.tld/*
* @license MIT License http://nrm.mit-license.org/2013
* @require
*/
// pair-script
// http://let.hatelabo.jp/noromanba/let/gYC-y8DN9c28Rw
// c.f. http://space.hatena.ne.jp/~/14217943783080751724#14217943783080751726+45
// http://space.hatena.ne.jp/~/14217943783080751724/14290001378108728700/3
(function () {
var tld, asin;
//*
if (!(tld = location.hostname.match(/^www\.amazon\.([a-z\.]+)/) || [])[1]) ||
!(asin = (location.pathname.match(/dp\/(\w+)/) || [])[1])) {
return;
}
/*/
var meta = (location.href.match(/^https?:\/\/www\.amazon\.([a-z\.]+).*\/dp\/(\w+)/) || []).slice(1);
if (meta.length < 2) return;
tld = meta[0], asin = meta[1];
//*/
var query = {
'normal': '#prodImageContainer img',
'other' : '#main-image',
'kindle': '#kib-ma-container-0 img'
};
query = Object.keys(query).map(function (k) { return query[k]; });
var img = (document.querySelector(query) || {}).src;
prompt('copy me', (img + ' \n' || '') + 'http://www.amazon.' + tld + '/dp/' + asin);
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。