A botton that redirects DuckDuckGo searches to Startpage
目前為
// ==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);