-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathduckduckGoogle.user.js
43 lines (34 loc) · 1.24 KB
/
duckduckGoogle.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ==UserScript==
// @name DuckDuckGoogle
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://duckduckgo.com/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
var urlParams = new URLSearchParams(window.location.search);
if(urlParams.has("q")) {
function addGoogleSearchButton() {
function searchGoogle() {
var searchText=document.querySelector("#search_form_input").value;
window.open("https://www.google.com/search?q="+searchText,"_self");
}
var dSearch=document.querySelector("#search_button");
var gSearch=dSearch.cloneNode(true);
dSearch.id="google_search";
var dSearchForm=document.querySelector("#header > div.header__search-wrap > div");
var gSearchForm=dSearchForm.cloneNode(false);
dSearchForm.insertAdjacentElement("afterend",gSearchForm);
gSearchForm.appendChild(gSearch);
gSearch.addEventListener("click",searchGoogle);
}
window.onload=function(){
setTimeout(addGoogleSearchButton,0);
}
//console.log("Userscript DuckDuckGoogle executed ---@v2---");
}
})();