Skip to content

Instantly share code, notes, and snippets.

@knsmr
Last active July 19, 2016 05:28
Show Gist options
  • Select an option

  • Save knsmr/7905610 to your computer and use it in GitHub Desktop.

Select an option

Save knsmr/7905610 to your computer and use it in GitHub Desktop.
//
// Bookmarklet
//
// Open up the corresponding translation in Japanese or original English article
// in a new window for http://techcrunch.com and http://jp.techcrunch.com
//
javascript:(function(){
_url=location.href;
if(_url.indexOf("http://jp.techcrunch") !== -1) {
_new_url = _url.replace("http://jp.", "https://").replace(/201[0-9\/]+/, "");
};
if(_url.indexOf("https://techcrunch") !== -1) {
_new_url = _url.replace("https://", "http://jp.");
_new_url = _new_url.replace(/(201[0-9])\/([0-9]+)\/([0-9]+)\//, function(match, y, m, d) {
return y + m + d;
});
};
window.open(_new_url);
})();
// the rule is like so:
// J-E
// http://jp.techcrunch.com/2013/12/06/20131205airfy-is-a-wi-fi-hotspot-that-you-wouldnt-be-ashamed-to-take-home-to-mother/
// -->
// http://techcrunch.com/airfy-is-a-wi-fi-hotspot-that-you-wouldnt-be-ashamed-to-take-home-to-mother/
// E-J
// http://techcrunch.com/2013/12/05/airfy-is-a-wi-fi-hotspot-that-you-wouldnt-be-ashamed-to-take-home-to-mother/
// -->
// http://jp.techcrunch.com/20131205airfy-is-a-wi-fi-hotspot-that-you-wouldnt-be-ashamed-to-take-home-to-mother/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment