Search code examples
javascriptgoogle-chromebookmarklet

How do I make a Google Chrome bookmarklet that fills a spot in a URL?


So there's a website I have to frequently interact with. The interface is kind of a pain so I'm trying to figure out a way around that by just changing the URL to what I want to input. I think I've almost got it... although I'm not the best at Javascript and it's been a while.

Example: www.examplewebsite.com/status/[spot I want to enter something]/blahblahblah/

What I've got so far is able to fill in the blank spot, but I'm not sure how to go about keeping the stuff that goes after it, cause it freaks the website out if it's gone.

Here's what I've got so far:

javascript:void(location.href='URL goes here'+window.prompt("enter search",""));

I tried

javascript:void(location.href='URL goes here'+window.prompt("enter search","")+href='URL continues here');

but that didn't work.


Solution

  • Try

    javascript:void(location.href='URL goes here'+window.prompt("enter search","")+'URL continues here');