Search code examples
javascriptbookmarklet

How can I create a bookmarklet to manipulate this URL?


I'm trying to create a bookmarklet which will change the URL of the current page as follows:

Orginal URL:

http://website.com/games/game-title/lobby/lobbyID/

Edited URL:

http://website.com/external/game-chooser/lobbyID/

In the original URL, "games" and "lobby" will always be exactly "games" and "lobby" but "game-title" and "lobbyID" will vary.

Thanks.


Solution

  • javascript:location.href='http://website.com/external/game-chooser/'+location.href.split('lobby/')[1]