Skip to content

Instantly share code, notes, and snippets.

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

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