/
duckduckgo.html
66 lines (65 loc) · 1.83 KB
/
duckduckgo.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head>
<title>DuckDuckGo Bar</title>
<style type="text/css">
body {
padding: 2px;
}
#ddgIcon {
height: 20px;
width: 20px;
display: inline;
}
#searchBox {
padding: 0;
margin: 0;
}
#searchField {
outline:none;
width:350px;
color:#222;
background:#FFF;
font-family:Century Gothic,Arial;
font-size:18px;
border:0 none;
margin:0 0 0 2px;
padding:0 5px;
-webkit-border-radius: 15px;
}
</style>
</head>
<body>
<a href="https://www.duckduckgo.com/"><img src="icon.png" id="ddgIcon" /></a>
<input id="searchField" type="text" name="q" onkeydown="if (event.keyCode == 13) document.getElementById('btnSearch').click()" />
<input type="submit" value="Duck Duck Go!" onclick="ddgSubmitSearch()" id="btnSearch" />
<script type="text/javascript">
function ddgSubmitSearch() {
var searchTerms = document.getElementById('searchField').value;
var secure = safari.extension.settings.getItem("ddgSecure");
if (secure) {
searchURL = "https://duckduckgo.com/?q=" + searchTerms;
}
else {
searchURL = "http://duckduckgo.com/?q=" + searchTerms;
}
ddgOpenStyle = safari.extension.settings.getItem("ddgOpenStyle");
switch(ddgOpenStyle) {
case 'newTab':
var tab = safari.application.activeBrowserWindow.openTab("foreground");
tab.url = searchURL;
break;
case 'bgTab':
var tab = safari.application.activeBrowserWindow.openTab("background");
tab.url = searchURL;
break;
case 'newWindow':
safari.application.openBrowserWindow();
case 'curTab':
safari.application.activeBrowserWindow.activeTab.url = searchURL;
break;
}
}
</script>
</body>
</html>