UnDuckButton

A botton that redirects DuckDuckGo searches to Startpage

目前为 2021-01-26 提交的版本。查看 最新版本

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

// ==/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);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址