forked from nqbao/chromesniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.html
70 lines (57 loc) · 1.53 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
66
67
68
69
70
<script type="text/javascript" src="common.js"></script>
<style type="text/css">
#app_list a {
margin-right: 4px;
}
</style>
<script language="javascript">
var bg = chrome.extension.getBackgroundPage();
chrome.tabs.getSelected(null,function(tab){
chrome.extension.sendRequest({msg: "get",tab: tab.id}, function(response){
var display = document.getElementById('app_list');
var apps = response.apps;
var html = '';
var appinfo = bg.appinfo;
var count = 0;
for (var appid in apps)
{
app = appinfo[appid] ? appinfo[appid] : {};
// i'm lazy to fill all kind of the information :(
if (!app.title) app.title = appid;
if (!app.url) app.url = appinfo[''].url.replace('%s',appid); // it's google one
if (!app.icon) app.icon = appinfo[''].icon;
if( apps[appid] != "-1")
{
app.title = appid + ' ' + apps[appid]
}
// use DOM to avoid error
var link = document.createElement('a');
var icon = document.createElement('img');
link.target = "_blank";
link.title = app.title;
link.href = app.url;
icon.alt = app.title;
icon.width = 16;
icon.height = 16;
icon.src = "apps/" + app.icon;
link.appendChild(icon);
display.appendChild(link);
count++;
}
if (count < 8) // correct the width for better view
{
display.style.width = (count*20) + "px";
}
else
{
display.style.width = "160px";
}
});
});
</script>
<div id="app_list" style="width: 10px;">
</div>
<!--
Chrome AppSniffer by Bao Nguyen <contact@nqbao.com>
Released under GLPv3 license.
-->