Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goeko/3894f300940bd313acf02046ab09f31b to your computer and use it in GitHub Desktop.
Save goeko/3894f300940bd313acf02046ab09f31b to your computer and use it in GitHub Desktop.
javascript:(function() {
var searchEngines = [
{ url: 'https://duckduckgo.com/?q=', param: 'q' },
{ url: 'https://www.google.de/search?q=', param: 'q' },
{ url: 'https://www.bing.com/search?q=', param: 'q' },
{ url: 'https://search.yahoo.com/search?p=', param: 'p' },
{ url: 'https://www.ecosia.org/search?q=', param: 'q' },
{ url: 'https://www.qwant.com/?q=', param: 'q' },
{ url: 'https://www.startpage.com/do/dsearch?query=', param: 'query' },
{ url: 'https://metager.de/meta/meta.ger3?eingabe=', param: 'eingabe' },
{ url: 'https://yandex.com/search/?text=', param: 'text' }
];
var currentEngine = searchEngines.find(engine => window.location.href.startsWith(engine.url));
if (currentEngine) {
var searchParams = new URLSearchParams(window.location.search);
var q = searchParams.get(currentEngine.param);
if (q !== null) {
var screenWidth = window.screen.availWidth;
var screenHeight = window.screen.availHeight;
var windowWidth = Math.floor(screenWidth / 3);
var windowHeight = Math.floor(screenHeight / 3);
searchEngines.forEach(function(engine, i) {
var newUrl = engine.url + encodeURIComponent(q);
var left = windowWidth * (i % 3);
var top = windowHeight * Math.floor(i / 3);
window.open(newUrl, '_blank', 'width=' + windowWidth + ',height=' + windowHeight + ',left=' + left + ',top=' + top);
});
} else {
alert('Kein "' + currentEngine.param + '" Parameter in der aktuellen URL gefunden.');
}
} else {
alert('Die aktuelle Seite ist keine bekannte Suchmaschine.');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment