Bookmarklet to replace the current domain with localhost:8000

17 January 2010   1 comment   Web development, Django

Mind That Age!

This blog post is 7 years old! Most likely, its content is outdated. Especially if it's technical.

Powered by Fusion×

If you, like me, have various projects that do things like OAuth on Twitter or Google or you have a development site that goes to PayPal. So you're doing some Django development on http://localhost:8000/foo and click, for example, to do an OAuth on Twitter with an app you have there. Then Twitter will redirect you back to the live site with which you've set it up. But you're doing local development so you want to go back to http://localhost:8080/... instead.

Add this bookmarklet: to localhost:8000 to your browser Bookmarks toolbar and it does exactly that.

Here's its code in more verbose form:

(function() { 
   a = function(){
     location.href = window.location.href.replace(/http:\/\/[^\/]+\//,
            'http://localhost:8000/')
   };
   if (/Firefox/.test(navigator.userAgent)) { 
     setTimeout(a,0)
   } else {
      a()
   }
 })()
Follow @peterbe on Twitter

Comments

eddie
Any way to get this working in Chrome?
Thank you for posting a comment

Your email will never ever be published


Related posts

Previous:
LastGraph - visualizing your Last.fm usage 08 January 2010
Next:
Tip: creating a Xapian database in Python 19 January 2010
Related by Keyword:
Registration and sign-in by email verification 29 April 2013
Beach volleyball bums 02 August 2012
Integrate BrowserID in a Tornado web app 22 November 2011
Too Cool For Me? 25 September 2011
Welcome to the world: DoneCal.com 22 November 2010
Related by Text:
iPhone push notifications for Twitter with Prowl 25 October 2009
Local Django development with Nginx 11 October 2010
10 Reasons I Love create-react-app 04 January 2017
How I profile my Nginx + proxy pass server 16 February 2011
To then() or to success() in AngularJS 27 November 2014