Skip to content

Instantly share code, notes, and snippets.

@CzBiX
Last active Aug 29, 2015
Embed
What would you like to do?
Amazon to CN
// ==UserScript==
// @name Amazon to CN
// @namespace CzBiX
// @include http://www.amazon.com/*
// @version 2
// @grant unsafeWindow
// ==/UserScript==
var window = unsafeWindow;
var $ = window.jQuery;
if (typeof $ === 'undefined') {
// maybe not product page, ignore it
return;
}
var link = $('link[rel="canonical"]')[0].href;
var asin = link.substr(link.indexOf('/dp/'));
var cnLink = 'http://www.amazon.cn' + asin;
var topBar = $('#nav-cross-shop-links');
topBar.append('<a target="_blank" href="' + cnLink + '">In China</a>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment