Skip to content

Instantly share code, notes, and snippets.

@pseudosavant
Created May 23, 2019 21:58
Show Gist options
  • Save pseudosavant/4ec73aee5f49d1e4dd427df646116ea6 to your computer and use it in GitHub Desktop.
Save pseudosavant/4ec73aee5f49d1e4dd427df646116ea6 to your computer and use it in GitHub Desktop.
Bookmarklet code for performing the same search you are already doing but on a different engine. Example: I search for 'shoes' on DuckDuckGo but I want to see if Bing or Google have more/better results.
(function(){
'use strict';
var engines = {
bing: 'https://www.bing.com/search?q=',
duckduckgo: 'https://duckduckgo.com/?q=',
google: 'https://www.google.com/search?q='
};
var engine = engines.duckduckgo; // Change to specify a different search engine
var query = document.location.search.substr(1).split('&');
var queryParam = '';
query.forEach(function(q) {
var split = q.split('=');
if (split[0] === 'q') {
queryParam = split[1];
return false;
}
});
if (queryParam.length > 0) {
document.location = engine + queryParam;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment