UnDuckButton

Buttons that redirect DuckDuckGo searches to other search engines

Stan na 01-02-2021. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        UnDuckButton
// @namespace   Violentmonkey Scripts
// @match       https://duckduckgo.com/*
// @grant       none
// @version     0.2.1
// @author      noarch
// @description Buttons that redirect DuckDuckGo searches to other search engines
// @license     WTFPL

// ==/UserScript==


// Searx instances from https://searx.neocities.org/nojs.html
// Updated 2021-01-15
var searxes = [
    "https://searx.ir/?q=",
    "https://search.stinpriza.org/?q=",
    "https://search.privacytools.io/searx/?q=",
    "https://search.azkware.net/?q=",
    "https://searx.openpandora.org/?q=",
    "https://trovu.komun.org/?q=",
    "https://searx.nakhan.net/?q=",
    "https://searx.nixnet.services/?q=",
    "https://searx.libmail.eu/?q=",
    "https://searx.elukerio.org/?q=",
    "https://searx.info/?q=",
    "https://searx.foo.li/?q="
];
var randomSearx = searxes[Math.floor(Math.random() * searxes.length)];

// Add more search engines here
var searchEngines = {
    //"Bing": "https://www.bing.com/search?q=", // Bing sucks, disabled by default
    "Google": "https://www.google.com/search?q=",
    "Random Searx": randomSearx,
  	"Startpage": "https://startpage.com/sp/search?query="
};

function getSearchQuery() {
    var input = document.getElementById("search_form_input").value;
    var inputEncoded = encodeURIComponent(input);

    return inputEncoded;
}

function addButton(text, href) {
    var btn = document.createElement("button");
    btn.innerHTML = text;
    btn.onclick = function() {
		window.location = href;
    };

    return btn;
}

function main() {
    // Create styles for the <div> containing the buttons
    var styles = ".redirectors {display: block; margin: 60px auto auto auto;  right: 4px; position: absolute; bottom: 0; top: 0;}";
    var styleSheet = document.createElement("style");
    styleSheet.type = "text/css";
    styleSheet.innerText = styles;

  	searchQuery = getSearchQuery(); // Failing here (if not on a result page) is fine, and intended

    var div = document.createElement("div");
    div.classList.add("redirectors");

    for (var searchEngine in searchEngines) {
        href = searchEngines[searchEngine] + searchQuery;
       div.appendChild(addButton(searchEngine, href));
    }

    document.head.appendChild(styleSheet);
    document.getElementById("header_wrapper").appendChild(div);
}

main();