Search code examples
javascriptgoogle-chromeshortcut

How to create a Chrome shortcut that prepends the current URL with another?


I wanted to create a shortcut on Chrome that will add a string to the front of the URL of the current page, and load this new page on the same window, for example:

I am currently at https://stackoverflow.com/ and when I press the shortcut, it will replace the URL with https://test.shortcut/https://stackoverflow.com/ and go to that new URL on the same window


Solution

  • So just make this into a bookmarklet, with the obvious modifications:

    <a href='javascript:window.location="https://www.google.com/search?q="+encodeURIComponent(window.location)'>drag me to bookmarks bar</a>