forked from dcampano/QuickPin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.html
65 lines (60 loc) · 1.33 KB
/
popup.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
<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="cleanTitles.js?v=1" type="text/javascript"></script>
<style>
body {
min-width:250px;
overflow-x:hidden;
}
.tab {
cursor: default;
border: 1px solid #ffffff;
padding-left: 2px;
font-family: 'Verdana';
font-size: 12px;
}
.tab:hover {
background: #ecf1f6;
border: 1px solid #ced9e4;
}
.favicon {
position: relative;
top: 2px;
width: 16px;
height: 16px;
}
img {
}
</style>
<div id="content"></div>
<script>
chrome.tabs.query( { "pinned": true }, function(tabs) {
console.log(tabs);
for(var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
var div = $('<div class=\'tab\'>');
var img = $('<img class=\'favicon\'>');
img.attr("src", tab.favIconUrl);
div.append(img);
var titleAssist = cleanTitle(tab);
div.append(" " + titleAssist);
div.attr("data-tab-id", tab.id);
div.click(function() {
var tabId = $(this).attr("data-tab-id");
chrome.tabs.update(parseInt(tabId), { "active": true });
});
$("#content").append(div);
}
});
function cleanTitle(tab){
for(var i = 0; i < cleanedTitles.length; i++){
var cleanTitle = cleanedTitles[i];
if(tab.url.indexOf(cleanTitle.search, 0) != -1){
return cleanTitle.title;
}
}
if(tab.title.length > 28){
return tab.title.substring(0, 25) + '...';
}
return tab.title;
}
</script>