Skip to content
This repository was archived by the owner on Apr 11, 2023. It is now read-only.

Commit 35ea04b

Browse files
author
Roland Eigelsreiter
committed
initial commit
1 parent 2381eb5 commit 35ea04b

12 files changed

+399
-0
lines changed

_locales/de/messages.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extDesc" : {"message" : "Optimierte Omnibox Verlauf Suche - Wie in Firefox Schnellsuche. Zum aktivieren gib $ und Tab/Leertaste in der Omnibox ein."},
3+
"searchInput" : {"message" : "Suche in Verlauf"},
4+
"omniboxDefault" : {"message" : "Benutze STRG+SHIFT+0 um die Schnellsuche zu öffnen ohne die Omnibox zu benötigen"},
5+
"help_1" : {"message" : "Wie funktioniert es"},
6+
"help_2" : {"message" : "Tie meist besuchten Einträge sind ganz oben. Gib ein was du von einer URL noch weißt, mehrere Wörter trennst du mit einem Leerzeichen. Beispiel: %s findet alle URL's die %s und %s beinhalten."},
7+
"help_3" : {"message" : "Einträge schnell löschen"},
8+
"help_4" : {"message" : "Die ENTF Taste löscht den gerade hervorgehobenen Eintrag"},
9+
"visits" : {"message" : "Besuche"}
10+
}

_locales/en/messages.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extDesc" : {"message" : "Optimized fuzzy omnibox history search - Like firefox quick history search. Type $ and tab/space to enable it in the omnibox."},
3+
"searchInput" : {"message" : "Search in history"},
4+
"omniboxDefault" : {"message" : "Use CTRL+SHIFT+0 to open quick history search without the omnibox"},
5+
"help_1" : {"message" : "How it works"},
6+
"help_2" : {"message" : "Most visited entries are on top. Type in what you know from an url, seperate multiple words by space to specify the search even more.\nExample: %s find all urls that contains %s and %s."},
7+
"help_3" : {"message" : "Quick delete entries"},
8+
"help_4" : {"message" : "DEL Key will remove the current highlighted entry from your history"},
9+
"visits" : {"message" : "Visits"}
10+
}

background.js

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
"use strict";
2+
/**
3+
* Background JS
4+
*/
5+
6+
// escape string for omnibox use
7+
var escapeUrl = function(url){
8+
return url.replace(/\&/g, "&amp;").replace(/\"/g, "&quot;").replace(/\'/g, "&apos;").replace(/\</g, "&lt;").replace(/\>/g, "&gt;")
9+
};
10+
11+
// unescape string for omnibox use
12+
var unescapeUrl = function(url){
13+
return url.replace(/\&quot\;/g, '"').replace(/\&apos\;/g, "'").replace(/\&lt\;/g, "<").replace(/\&gt\;/g, ">").replace(/\&amp\;/g, "&");
14+
};
15+
16+
// on do search - when user typed in the omnibox
17+
var onSearch = function(text, suggest){
18+
var found = [];
19+
var s = text.trim().split(" ");
20+
var sRegex = s;
21+
for(var i in sRegex) {
22+
sRegex[i] = {"regex" : new RegExp(sRegex[i].replace(/[^0-9a-z]/ig, "\\$&"), "ig"), "val" : s[i]};
23+
}
24+
25+
// go through each item and do the search thingy
26+
itemsCache.forEach(function(item){
27+
var ok = true;
28+
sRegex.forEach(function(val){
29+
if(item.url.match(/^chrome/) || !item.url.match(val.regex)){
30+
ok = false;
31+
return false;
32+
}
33+
});
34+
if(ok) found.push(item);
35+
});
36+
37+
// resort by visit count
38+
found.sort(function(a, b){
39+
if(a.visitCount > b.visitCount) return -1;
40+
if(a.visitCount < b.visitCount) return 1;
41+
return 0;
42+
});
43+
44+
// just slice the best 50 entries
45+
found = found.slice(0, 50);
46+
47+
// generate suggestions array
48+
var suggestions = [];
49+
found.forEach(function(item){
50+
var u = escapeUrl(item.url);
51+
var uDesc = u;
52+
sRegex.forEach(function(val){
53+
uDesc = uDesc.replace(val.regex, '<match>'+val.val+'</match>');
54+
});
55+
suggestions.push({
56+
"content" : u,
57+
"description" : '<url>'+uDesc+'</url> :: <dim>'+item.visitCount+' '+chrome.i18n.getMessage("visits")+'</dim> '+(item.title && item.title.length ? " :: "+escapeUrl(item.title) : "")
58+
});
59+
});
60+
61+
// omnibox suggest
62+
if(suggest) suggest(suggestions);
63+
return suggestions;
64+
};
65+
66+
// cache history entries
67+
var itemsCache = [];
68+
var updateCache = function(){
69+
chrome.history.search({"text" : "", "maxResults" : 2147483647, "startTime" : 0}, function(items){
70+
itemsCache = items;
71+
});
72+
};
73+
74+
// refresh items cache every 5 minutes
75+
setInterval(updateCache, 5 * 60 * 1000);
76+
77+
// on init create the cache
78+
updateCache();
79+
80+
// default suggestion text
81+
chrome.omnibox.setDefaultSuggestion({"description" : chrome.i18n.getMessage("omniboxDefault")});
82+
83+
// when user typed in the omnibox
84+
chrome.omnibox.onInputChanged.addListener(onSearch);
85+
86+
// on enter or select the current entry
87+
chrome.omnibox.onInputEntered.addListener(function(text, type){
88+
chrome.tabs.getSelected(null, function(tab){
89+
chrome.tabs.update(tab.id, {url : text}, function(){
90+
91+
});
92+
});
93+
});
94+
95+
// key shortcuts
96+
chrome.commands.onCommand.addListener(function(command) {
97+
if(command == "open"){
98+
var w = 600;
99+
var h = 400;
100+
var l = screen.width / 2 - w / 2;
101+
var t = screen.height / 2 - h / 2;
102+
chrome.windows.create({"url" : chrome.extension.getURL("options.html"), "type" : "popup", "width" : w, "height" : h, "left" : l, "top" : t}, function(){
103+
104+
});
105+
}
106+
});
107+
108+
// on connect from options page
109+
chrome.extension.onConnect.addListener(function(port) {
110+
if(port.name == "bomnibox"){
111+
port.onMessage.addListener(function(data) {
112+
if(data.action == "search"){
113+
if(port) {
114+
port.postMessage({"action" : "search-callback", "suggestions" : onSearch(data.text, null)});
115+
}
116+
}
117+
if(data.action == "delete"){
118+
if(port) {
119+
chrome.history.deleteUrl({"url" : unescapeUrl(data.url)}, updateCache);
120+
}
121+
}
122+
});
123+
}
124+
port.onDisconnect.addListener(function(){
125+
port = null;
126+
});
127+
});
128+

img/icon-128.png

6.7 KB
Loading

img/icon-16.png

1.08 KB
Loading

img/icon-48.png

3.29 KB
Loading

img/icon-trans-300.png

8.44 KB
Loading

jquery.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "Bomnibox - Better Omnibox",
3+
"short_name": "bomnibox",
4+
"version": "1.0.1",
5+
"manifest_version": 2,
6+
"description": "__MSG_extDesc__",
7+
"homepage_url": "https://github.com/brainfoolong/bomnibox",
8+
"minimum_chrome_version" : "20.0",
9+
"author": "BrainFooLong",
10+
"default_locale" : "en",
11+
"icons": {
12+
"16": "img/icon-16.png",
13+
"48": "img/icon-48.png",
14+
"128": "img/icon-128.png"
15+
},
16+
"omnibox": { "keyword" : "$" },
17+
"background": {
18+
"scripts": ["background.js"],
19+
"persistent": false
20+
},
21+
"permissions": [
22+
"history",
23+
"tabs"
24+
],
25+
"commands": {
26+
"open": {
27+
"suggested_key": {
28+
"default": "Ctrl+Shift+0",
29+
"mac": "Command+Shift+0"
30+
},
31+
"global": true,
32+
"description": "Open Bomnibox"
33+
}
34+
}
35+
}

options.css

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
body{
2+
text-align: center;
3+
font-family: roboto, arial;
4+
font-size: 14px;
5+
line-height: 18px;
6+
color:#222222;
7+
overflow-x:hidden;
8+
direction: __MSG_@@bidi_dir__;
9+
}
10+
11+
.page-center{
12+
margin: 0px auto;
13+
text-align: center;
14+
max-width: 580px;
15+
min-width: 300px;
16+
padding:10px;
17+
}
18+
19+
.search,
20+
#results,
21+
#help{
22+
padding:10px;
23+
color:#777777;
24+
font-weight: 300;
25+
border:1px solid #e5e5e5;
26+
margin-bottom: 20px;
27+
width:95%;
28+
font-family: roboto, arial;
29+
text-transform: uppercase;
30+
font-size: 17px;
31+
line-height: 20px;
32+
}
33+
34+
.search{
35+
background: url(img/icon-48.png) no-repeat left center;
36+
height:28px;
37+
padding-left: 55px;
38+
width:87%;
39+
outline: none;
40+
position: relative;
41+
left:-3px;
42+
}
43+
44+
.help-icon{
45+
padding:5px;
46+
color:white;
47+
background: #e5e5e5;
48+
border-radius:10px;
49+
font-weight: bold;
50+
text-align: center;
51+
position: absolute;
52+
right:33px;
53+
top:30px;
54+
cursor: pointer;
55+
z-index:1;
56+
}
57+
58+
#results,
59+
#help{
60+
text-align: left;
61+
font-size: 14px;
62+
line-height: 18px;
63+
text-transform: none;
64+
color:#222222;
65+
display: none;
66+
}
67+
68+
#help h3{
69+
padding: 0px;
70+
margin: 0px;
71+
font-weight: 100;
72+
margin-bottom: 10px;
73+
font-size: 24px;
74+
line-height: 28px;
75+
text-transform: uppercase;
76+
}
77+
78+
#results div{
79+
padding:4px;
80+
text-overflow: ellipsis;
81+
overflow: hidden;
82+
white-space: nowrap;
83+
cursor: pointer;
84+
position: relative;
85+
}
86+
87+
#results div.active,
88+
#results div:hover{
89+
background: #48A4FF;
90+
color:white;
91+
}
92+
93+
#results div:hover{
94+
background: #AAD5FF;
95+
}
96+
97+
#results div.active{
98+
text-overflow:clip;
99+
white-space: normal;
100+
}
101+
102+
url{
103+
color:green;
104+
}
105+
106+
match{
107+
font-weight: bold;
108+
}
109+
110+
dim{
111+
color:#777777;
112+
}

options.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5+
<title>Bomnibox - Better Omnibox</title>
6+
<link rel="stylesheet" type="text/css" href="options.css">
7+
<script type="text/javascript" src="jquery.js"></script>
8+
<script type="text/javascript" src="options.js"></script>
9+
</head>
10+
<body>
11+
<div class="page-center">
12+
<span class="help-icon">?</span>
13+
<input type="text" class="search"/>
14+
<div id="help"></div>
15+
<div id="results"></div>
16+
</div>
17+
</body>
18+
</html>

0 commit comments

Comments
 (0)