Skip to content

Instantly share code, notes, and snippets.

@CzBiX
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CzBiX/63d226cc09cc85c3031f to your computer and use it in GitHub Desktop.
Save CzBiX/63d226cc09cc85c3031f to your computer and use it in GitHub Desktop.
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