Skip to content

Instantly share code, notes, and snippets.

@luckycdev
Last active April 27, 2022 17:12
Show Gist options
  • Save luckycdev/92a2f348057101950765510fea9a41ea to your computer and use it in GitHub Desktop.
Save luckycdev/92a2f348057101950765510fea9a41ea to your computer and use it in GitHub Desktop.
search using Google with a bookmarklet - easily changeable - google search bookmarklet

Search Google with a bookmarklet, easily changeable link, change where it says var a="https://google.com?q=";

you might have to adjust the url to what the url is when searching if using a different link


Code:

javascript:
var a="https://google.com/search?q=";
var b=prompt("What would you like to search on Google?", "Search");
if(b==="")
{
alert("invalid response");
}
else if (b===" ")
{
alert("invalid response");
}
else if (b!=null)
{
open(a+encodeURI(b));
}

Bookmarklet:

javascript:var a="https://google.com/search?q="; var b=prompt("What would you like to search on Google?", "Search"); if(b===""){alert("invalid response");}else if (b===" "){alert("invalid response");} else if (b!=null){open(a+encodeURI(b));}
javascript:var a="https://google.com/search?q="; var b=prompt("What would you like to search on Google?", "Search"); if(b===""){alert("invalid response");}else if (b===" "){alert("invalid response");} else if (b!=null){open(a+encodeURI(b));}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment