Amazon img + asin
by
noromanba
2013-07-26 [2013/07/26 07:19:46]
prompt minified Amazon link with img; LGTM for Hatena Space
@@ -8,12 +8,12 @@
// c.f. http://space.hatena.ne.jp/~/14217943783080751724#14217943783080751726+34
(function () {
- var asin, img;
- if (!/^www\.amazon\.(?:co\.jp|com)/.test(location.hostname) ||
- !(asin = (/\/(?:dp|ASIN)\/\w+/.exec(location.pathname) || [])[0]) ||
- !(img = (document.querySelector('#prodImageContainer img') || {}).src)) {
+ var tld, asin;
+ if (!(tld = (/^www\.amazon\.([a-z\.]+)/.exec(location.hostname) || [])[1]) ||
+ !(asin = (document.querySelector('#ASIN') || {}).value)) {
return;
}
+ var img = (document.querySelector('#prodImageContainer img, #main-image, #kib-ma-container-0 img') || {}).src;
- prompt('copy me', img + '\n' + 'http://www.amazon.co.jp' + asin);
-})();
+ prompt('copy me', (img + '\n' || '') + 'http://www.amazon.' + tld + '/dp/' + asin);
+})();
(function () {
var tld, asin;
if (!(tld = (/^www\.amazon\.([a-z\.]+)/.exec(location.hostname) || [])[1]) ||
!(asin = (document.querySelector('#ASIN') || {}).value)) {
return;
}
var img = (document.querySelector('#prodImageContainer img, #main-image, #kib-ma-container-0 img') || {}).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 です。