-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfromDuckToGoogle.user.js
42 lines (32 loc) · 1.58 KB
/
fromDuckToGoogle.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
// ==UserScript==
// @name GoTo google in duck
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author You
// @updateURL https://github.com/MrSauna/tampermonkey-scripts/raw/master/fromDuckToGoogle.user.js
// @downloadURL https://github.com/MrSauna/tampermonkey-scripts/raw/master/fromDuckToGoogle.user.js
// @match https://duckduckgo.com/*q=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var input_field_element = document.getElementById("search_form_input")
var search_string = input_field_element.value
var search_url = "https://www.google.com/search?q=" + search_string
var parent_element = document.getElementById("search_form")
var parent_element_width = parent_element.clientWidth
var new_element_font_size = Math.floor(input_field_element.clientHeight * 0.75)
var new_element_string = '<div style="position:absolute; font-size: '+new_element_font_size+'px;'
+'text-align:center;height:'+input_field_element.clientHeight+'px;'
+'left:'+parent_element_width+'px;padding-left:7px;top:0;line-height:normal;">'
+'<a style="vertical-align: middle;" href="'+search_url+'" >G</a></div>'
function createElementFromHTML(htmlString) {
var div = document.createElement('div');
div.innerHTML = htmlString.trim();
// Change this to div.childNodes to support multiple top-level nodes
return div.firstChild;
}
var new_element = createElementFromHTML(new_element_string)
parent_element.appendChild(new_element)
})();