Last active
September 4, 2015 00:15
-
-
Save umq/233917 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Amazon short URI | |
// @namespace http://www.misao.gr.jp/~koshian/ | |
// @description Short URI for amazon. | |
// @include http://www.amazon.co.jp/* | |
// @include http://amazon.co.jp/* | |
// @include http://www.amazon.jp/* | |
// @include http://amazon.jp/* | |
// originally: http://userscripts.org/scripts/show/24846 | |
// ==/UserScript== | |
(function() { | |
var asin = document.getElementById('ASIN'); | |
var base = 'http://www.amazon.co.jp/'; | |
var dirs = ['dp/', 'o/ASIN/', 'gp/product/']; | |
var panel; | |
if (asin) { | |
var target = document.getElementById('PrimeStripeContent'); | |
var block = document.createElement('div'); | |
block.setAttribute('style', 'text-align: right;'); | |
panel = '<select id="ASUselect" onChange="' + | |
'document.getElementById(\'ASUtext\').value =\'' + base +'\'+' + | |
'document.getElementById(\'ASUselect\').value + ' + | |
'document.getElementById(\'ASIN\').value; ">'; | |
for( var i = 0; i < dirs.length; i++ ){ | |
var el = '<option value="ASUValue" selected>ASUValue</option>'; | |
if(location.pathname.indexOf(dirs[i]) != 1) { | |
el = el.replace(/ selected/g, ""); | |
} | |
panel += el.replace(/ASUValue/g, dirs[i]); | |
} | |
panel += '</select>'; | |
panel += '<input type="text" size="30" id="ASUtext"' + | |
'readonly="readonly" onfocus="this.select();">'; | |
panel += '<input type="button" value = "Go!" ' + | |
'onClick="location.href = ASUtext.value;">'; | |
block.innerHTML = panel; | |
target.appendChild(block); | |
var view = document.getElementById('ASUtext'); | |
var select = document.getElementById('ASUselect'); | |
view.value = base + select.value + asin.value; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment