Last active
September 19, 2022 03:18
-
-
Save jareha/f61e02ee4d3c039476c37a5ea124aff0 to your computer and use it in GitHub Desktop.
Bookmarklet to toggle between `localhost` and production
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jshint esversion: 8 */ | |
(function () { | |
const domain = "https://example.com"; | |
const isLocalhost = window.location.href.indexOf("localhost") >= 0; | |
const localhost = "http://localhost:8080"; | |
const pathname = window.location.pathname; | |
const url = isLocalhost ? (domain + pathname) : (localhost + pathname); | |
window.location = url; | |
})(); | |
// javascript:(function(){const domain="https://example.com";const isLocalhost=window.location.href.indexOf("localhost")>=0;const localhost="http://localhost:8080";const pathname=window.location.pathname;const url=isLocalhost?(domain+pathname):(localhost+pathname);window.location=url})(); | |
// Minified at https://duckduckgo.com/?q=javascript+minifier |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment