Skip to content

Instantly share code, notes, and snippets.

@jelder
Last active December 27, 2015 19:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jelder/7377297 to your computer and use it in GitHub Desktop.
Save jelder/7377297 to your computer and use it in GitHub Desktop.
Bookmarklet to toggle between Pow and Production

Pow Toggle Bookmarklet

Ever come across something funky in production and want to see it in your development environment? Use Pow? This is for you. Make a new bookmark for this location:

javascript:(function()%7Bif%20(%2Fhttp%3A.*%5C.dev%2F.test(window.location.origin))%20%7Burl%20%3D%20window.location.href.replace(%2F%5Ehttp%3A%2F%2C%20'https%3A').replace(%2F.dev%2F%2C'.com')%3Bwindow.open(url)%3B%7D%20else%20%7Burl%20%3D%20window.location.href.replace(%2F%5Ehttps%3A%2F%2C%20'http%3A').replace(%2F.com%2F%2C'.dev')%3B%3Bwindow.open(url)%3B%7D%7D)()

If you want to edit this, first copy and paste the JavaScript below into a bookmarklet creator. I used http://mrcoles.com/bookmarklet/ but others might be nice, too.

if (/http:.*\.dev/.test(window.location.origin)) {
url = window.location.href.replace(/^http:/, 'https:').replace(/.dev/,'.com');
window.open(url);
} else {
url = window.location.href.replace(/^https:/, 'http:').replace(/.com/,'.dev');;
window.open(url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment