Created
May 23, 2019 21:58
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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