// ==UserScript==
// @name Amazon.com Shipping and Postage Checker
// @name:ja Amazonアメリカ 送料確認
// @author yasuikamo
// @description This extension is able to check shipping and postage confirmation of Amazon products in the United States.
// @description Supported country is Asia, Europe and other.
// @description:ja Amazonアメリカから日本までの送料を確認できるエクステンション。
// @description:ja Amazon.comの商品ページに転送サービスの送料、出品者の送料を確認できるWebサービスのリンクを追加します。
// @version 0.2
// @include http://www.amazon.com/*
// @require api
// @history 0.2 Add Support Country(Asia, Europe and other).
// @history 0.1 Initial Creation
// @history:ja 0.2 リンクが表示されないバグを修正
// @history:ja 0.1 新規作成
// @gallery-id luzyfqblpctsutsbjwhndgrfpvwnfetg
// ==/UserScript==
if (!this.GM_getValue || this.GM_getValue.toString().indexOf("not supported")>-1)
{
this.GM_getValue=function (key,def) {
var getitemdata = window.localStorage.getItem(key);
if(getitemdata == null)
{
return def;
}
else
{
return window.localStorage.getItem(key);
}
};
this.GM_setValue=function (key,value) {
return window.localStorage.setItem(key, value);
};
}
function main()
{
if( document.getElementById('dpSearchKeyword') && document.getElementById('addToCart'))
{
var asins = document.getElementsByName("a");
var adds = document.getElementsByName("o");
if(asins.length > 0 && adds.length > 0)
{
if(getLocale() == "ja")
{
var data1 = createButton('tenso', "転送サービスの送料を確認");
var data2 = createButton('shupin', "出品者の送料を確認");
var button1 = document.createElement('div');
var button2 = document.createElement('div');
button1.innerHTML = "
" + data1;
button2.innerHTML = data2;
document.getElementById('addToCart').parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(button1);
document.getElementById('addToCart').parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(button2);
document.getElementById("tenso").addEventListener("click", sendTensoPage, false);
document.getElementById("shupin").addEventListener("click", sendShupinPage, false);
}
else
{
var data1 = createButton('shupin', "Check Shipping of the seller.");
var button1 = document.createElement('div');
button1.innerHTML = "
" + data1;
document.getElementById('addToCart').parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(button1);
document.getElementById("shipto").addEventListener("change", setShipto, false);
document.getElementById("shupin").addEventListener("click", sendShupinPage, false);
selectedShipto();
}
}
}
else if( document.getElementById('ASIN') || document.getElementById('addToCart'))
{
var loadArea = document.createElement('div');
loadArea.style.border = "solid 1px #6DAEE1";
loadArea.style.fontSize = "1.1em";
loadArea.style.textAlign = "center";
loadArea.style.verticalAlign = "middle";
loadArea.style.borderRadius = "4px";
loadArea.style.marginTop = "5px";
if(document.getElementById('ASIN'))
{
var trObj = document.createElement('tr');
var tdObj = document.createElement('td');
var tableObj = document.getElementsByTagName("table");
for(var i=0; i
送料を確認";
displayData += "
";
displayData += "
";
loadArea.innerHTML = displayData;
document.getElementById("tenso").addEventListener("click", sendTensoPage, false);
document.getElementById("shupin").addEventListener("click", sendShupinPage, false);
}
else
{
var displayData = "
Check Shipping and Postage.
";
displayData += "
Shipped to
";
displayData += "
";
loadArea.innerHTML = displayData;
document.getElementById("shupin").addEventListener("click", sendShupinPage, false);
selectedShipto();
}
}
}
function createButton(id, name)
{
var html = "";
if(getLocale() == "ja")
{
html +="
";
}
else
{
html +="
";
}
return html;
}
function getASIN()
{
var asin = "";
if(document.getElementById('ASIN'))
{
asin = document.getElementById('ASIN').value;
}
else if(document.getElementById('addToCart'))
{
var form = document.getElementById('addToCart');
asin = form.a.value;
}
return asin;
}
function sendTensoPage()
{
location.href = "http://www.yasui-kamo.com/forward/?asin="+getASIN();
}
function sendShupinPage()
{
if(getLocale() == "ja")
{
location.href = "http://www.yasui-kamo.com/shiprate/?asin="+getASIN();
}
else
{
var selectIdx = document.getElementById('shipto').selectedIndex;
var shipto = document.getElementById('shipto').options[selectIdx].value;
GM_setValue("shipto", shipto);
location.href = "http://www.yasui-kamo.com/shiprate2/?asin="+getASIN()+"&shipto="+shipto;
}
}
function setShipto()
{
var selectIdx = document.getElementById('shipto').selectedIndex;
var shipto = document.getElementById('shipto').options[selectIdx].value;
document.getElementById('shiptofrm').value = shipto;
}
function selectedShipto()
{
var shipto = GM_getValue("shipto", "as");
var shiptoObj = document.getElementById('shipto').options;
for(var i=0; i