アフィリエイトを加速する!「Amazon Quick Affiliate (JP) 」具体例とちょっとの改造。
Amazonアソシエイトを便利に利用するためにamazletを使ってた。
それで、ちょっとだけ、いらないところは消したりしてた。
メンドクサイなと思って、検索したら、Greasemonkeyで「Amazon Quick Affiliate」という
便利なモノがあった。
Amazonの商品を最速でブログにコピペできるGreasemonkey「Amazon Quick Affiliate (JP)」
「Amazon Quick Affiliate」アップデート(著者、出版社、発売日の追加など)
Amazon Quick Affiliate (JP) のインストール
テンプレートで使用可能なキーワードがあって、オリジナルのテンプレートに
カスタマイズすることができる。
- ${aid} : アソシエイトID
- ${asin} : ASINコード
- ${title} : 商品名
- ${url} : 商品URL (アソシエイトID含む)
- ${imgid} : 画像ID
- ${img} : 画像URL (${imgid}含む)
- ${author} : 著者
- ${publisher} : 出版社
- ${published} : 発行日
少し改造してみた。
表示項目の変更
オリジナル | 改造後 |
---|---|
短縮URL | アフィリエイト |
テキストリンク | はてな用 |
画像リンク | Twitter用 |
1)短縮URL
http://www.amazon.co.jp/dp/{$asin}/ 形式で、http://amzn.to/ 形式ではないので、
AmazonアソシエイトのURLを表示するようにした。
短縮を使うシーンって今のところ、Twitterなので、Tweenが勝手に短縮してくれるから
あまり必要なさそうなので、Amazonアソシエイトにした。
3)画像リンク
Twitter用に『タイトル』 http://〜〜 に変更
テンプレート用のキーワードに価格を追加
値下げしてる場合などの処理のうまい切り分け方法がわからないから
取得できなかったら、try/catchで無視するようにしてしまった。。。 (゜゜;)バキッ\(-_-;)
改造前後のdiff
diff U3 orginal/amazon_quick_affiliate_j.user.js orangeclover/amazon_quick_affiliate_j.user.js --- orginal/amazon_quick_affiliate_j.user.js Fri Nov 05 22:58:23 2010 +++ orangeclover/amazon_quick_affiliate_j.user.js Sun Dec 05 15:36:42 2010 @@ -6,6 +6,7 @@ // @version 1.9.0 // ==/UserScript== +//orangeclover version (function() { var w = (typeof(unsafeWindow) != 'undefined') ? unsafeWindow : window; @@ -32,6 +33,7 @@ var author = ''; var publisher = ''; var published = ''; + var price = ''; // User Settings (default) var affiliate_id = 'aqajp-22'; @@ -162,17 +164,17 @@ custom_tag = custom_tag.replace(/\${author}/g, author); custom_tag = custom_tag.replace(/\${publisher}/g, publisher); custom_tag = custom_tag.replace(/\${published}/g, published); + custom_tag = custom_tag.replace(/\${price}/g, price); - // Text Link + // hatena Link //document.getElementById('affiliate_text_link').innerHTML // = '<a href="'+url+'" target="_blank">'+title+'</a>'; - document.getElementById('affiliate_text_tag').value = '<a href="'+url+'" target="_blank">'+title+'</a>'; + document.getElementById('affiliate_hatena_tag').value = '[' + url + ':title=' + title + ']'; - // Image Link + // Twitter Link //document.getElementById('affiliate_image_link').innerHTML // = '<a href="'+url+'" target="_blank"><img src="'+img+'" alt="'+asin+'" border="0" /></a>'; - document.getElementById('affiliate_image_tag').value - = '<a href="'+url+'" target="_blank"><img src="'+img+'" alt="'+asin+'" border="0" /></a>'; + document.getElementById('affiliate_twitter_tag').value = '『' + title + '』' + url ; // Custom Link document.getElementById('affiliate_custom_link').innerHTML @@ -243,6 +245,69 @@ break; } } + + //price + var priceBlockLabelPrice = ''; + var priceBlockLabel = ''; + try{ + var price_block = document.getElementById('priceBlock'); + var product = price_block.getElementsByTagName('table')[0].getElementsByTagName('tbody')[0].getElementsByTagName('tr') + for ( var i=0; i < product.length; i++ ) { + try{ + var table = product[i].getElementsByTagName("td"); + if(table[0].innerHTML.indexOf("価格") == 0){ + try{ + if(table[1].getElementsByTagName("b")[0].getAttribute("class") =="priceLarge"){ + priceBlockLabel = table[1].getElementsByTagName("b")[0].innerHTML; + } + }catch(e){ + /* NOP */ + } + + try{ + if(table[1].getElementsByTagName("span")[0].getAttribute("class") =="priceLarge"){ + priceBlockLabel = table[1].getElementsByTagName("span")[0].innerHTML; + } + }catch(e){ + /* NOP */ + } + } + + + if(table[0].innerHTML.indexOf("参考価格") == 0){ + try{ + if(table[1].getElementsByTagName("b")[0].getAttribute("class") =="listprice"){ + priceBlockLabelPrice = table[1].getElementsByTagName("b")[0].innerHTML; + } + }catch(e){ + /* NOP */ + } + + try{ + if(table[1].getElementsByTagName("span")[0].getAttribute("class") =="listprice"){ + priceBlockLabelPrice = table[1].getElementsByTagName("span")[0].innerHTML; + } + }catch(e){ + /* NOP */ + } + } + }catch(e){ + /* NOP */ + } + } + }catch(e){ + price +='出品者からお求めいただけます。</br>'; + } + if ( priceBlockLabelPrice != '' ){ + price += '参考価格 : <del>' + priceBlockLabelPrice + ' </del></br>'; + } + if ( priceBlockLabel != '' ){ + price += '価格: ' + priceBlockLabel + ' </br>'; + } + + price +='価格は記載時点のものです。購入前にAmazonでご確認ください。'; + + //console.log(publisher); //console.log(published); @@ -306,6 +371,7 @@ + '<input type="hidden" id="affiliate_author" value="' + this.esc(author) + '" />' + '<input type="hidden" id="affiliate_publisher" value="' + this.esc(publisher) + '" />' + '<input type="hidden" id="affiliate_published" value="' + this.esc(published) + '" />' + + '<input type="hidden" id="affiliate_price" value="' + this.esc(price) + '" />' /* Header */ + '<div id="aqaHeader" style="'+styles.aqaHeader+'">' + '<span style="margin-right:10px;">Amazon Quick Affiliate</span>' @@ -314,14 +380,14 @@ + '<a id="aqaButtonCustomOff" style="'+styles.aqaButtonCustomOff+'" href="javascript:void(0);">カスタムリンク</a>' + '<a id="aqaButtonSettingOn" style="'+styles.aqaButtonSettingOn+'" href="javascript:void(0);">設定</a>' + '<a id="aqaButtonSettingOff" style="'+styles.aqaButtonSettingOff+'" href="javascript:void(0);">設定</a>' - + '<span style="'+styles.mini_span+'">短縮URL:' - + '<input type="text" id="display_shorturl" value="http://www.amazon.co.jp/dp/' + asin + '/" />' + + '<span style="'+styles.mini_span+'">アフィリエイト:' + + '<input type="text" id="affiliate__url" value="http://www.amazon.co.jp/exec/obidos/ASIN/' + asin + '/associates-tracking-22/" />' + '</span>' - + '<span style="'+styles.mini_span+'">テキストリンク:' - + '<input type="text" id="affiliate_text_tag" size="40" value="" style="width:100px;" />' + + '<span style="'+styles.mini_span+'">はてな用:' + + '<input type="text" id="affiliate_hatena_tag" size="40" value="" style="width:100px;" />' + '</span>' - + '<span style="'+styles.mini_span+'">画像リンク:' - + '<input type="text" id="affiliate_image_tag" size="40" value="" style="width:100px;" />' + + '<span style="'+styles.mini_span+'">Twitter用:' + + '<input type="text" id="affiliate_twitter_tag" size="40" value="" style="width:100px;" />' + '</span>' + '</div>' /* Custom Block */ @@ -376,6 +442,7 @@ + '<strong>${author}</strong> : 著者<br />' + '<strong>${publisher}</strong> : 出版社<br />' + '<strong>${published}</strong> : 発行日<br />' + + '<strong>${price}</strong> : 価格<br />' + '</td>' + '</tr>' + '</table>'
カスタムリンクの設定
<div class="affiliate-box" style="margin-bottom:0px;"> <div class="affiliate-image" style="float:left;margin:0px 12px 1px 0px;"> <a href="${url}" name="affiliatelink" target="_blank"> <img src="${img}" height="180px" alt="${title}" style="border: none;" /> </a> </div> <div class="affiliate-info" style="line-height:120%; margin-bottom: 10px"> <div class="affiliate-name" style="margin-bottom:10px;line-height:120%"> <a href="${url}" name="affiliatelink" target="_blank">${title} </a> </div> <div class="affiliate-detail"> ${author} <br /> ${price} <br /> <br /> </div> <div class="affiliate-sub-info" style="float: left;"> <div class="affiliate-link" style="margin-top: 5px"> <a href="${url}" name="affiliatelink" target="_blank">Amazon.co.jp で詳細を見る </a> </div> </div> </div> <div class="affiliate-footer" style="clear: left"> </div> </div>