UnDuckButton

A botton that redirects DuckDuckGo searches to Startpage

Ekde 2021/01/26. Vidu La ĝisdata versio.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        UnDuckButton
// @namespace   Violentmonkey Scripts
// @match       https://duckduckgo.com/*
// @grant       none
// @version     0.1.1
// @author      noarch
// @description A botton that redirects DuckDuckGo searches to Startpage
// @license     WTFPL

// ==/UserScript==

var styles = "#redirector {display: block; margin: 64px auto auto 16px; height: 32px; right: 6px; position: absolute; bottom: 0; top: 0;}";
var styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);

function addButton(text, href) {
    var btn = document.createElement("BUTTON");
    btn.innerHTML = text;
    btn.id = "redirector";
    btn.onclick = function() {
         window.location = href;
    };
    document.getElementById("header_wrapper").appendChild(btn);
}

function getSearchQuery() {
    var input = document.getElementById("search_form_input").value;
    var inputEncoded = encodeURIComponent(input);
    return "https://startpage.com/sp/search?query=" + inputEncoded;
}

try {
    var searchQuery = getSearchQuery();
} catch (error) {
    return false;
}

addButton("Search on Startpage", searchQuery);