Skip to content

Instantly share code, notes, and snippets.

@luckycdev
Last active April 27, 2022 18:07
Show Gist options
  • Save luckycdev/e28f6a49f566d78130eb21afa722f7fd to your computer and use it in GitHub Desktop.
Save luckycdev/e28f6a49f566d78130eb21afa722f7fd to your computer and use it in GitHub Desktop.
search using stackoverflow with a bookmarklet - easily changeable - stackoverflow search bookmarklet

Search stackoverflow with a bookmarklet, easily changeable link, change where it says var a="https://stackoverflow.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://stackoverflow.com/search?q=";
var b=prompt("What would you like to search on stackoverflow?", "How to...");
if(b==="")
{
alert("invalid response");
}
else if (b===" ")
{
alert("invalid response");
}
else if (b!=null)
{
open(a+encodeURI(b));
}

Bookmarklet:

javascript:var a="https://stackoverflow.com/search?q="; var b=prompt("What would you like to search on stackoverflow?", "How to..."); if(b===""){alert("invalid response");}else if (b===" "){alert("invalid response");} else if (b!=null){open(a+encodeURI(b));}
javascript:var a="https://stackoverflow.com/search?q="; var b=prompt("What would you like to search on stackoverflow?", "How to..."); 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