Skip to content

Commit 5e11d78

Browse files
committed
Merge pull request #2 from deepak1556/robo/fix
Changes for compatibility with manifest V2
2 parents 13ea595 + c24e1ca commit 5e11d78

File tree

6 files changed

+238
-259
lines changed

6 files changed

+238
-259
lines changed
Lines changed: 5 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -1,187 +1,5 @@
1-
<script>
2-
/* See license.txt for terms of usage */
3-
4-
// *************************************************************************************************
5-
6-
//var bookmarlet = "javascript:(typeof Firebug!='undefined')?Firebug.chrome.toggle():(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E=F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLiteBookmarlet','1.3.0.1','firebug.jgz','skin/xp/sprite.png','https://getfirebug.com/releases/lite/beta/','#startOpened,showIconWhenHidden=false');";
7-
var firebugVersion = "Firebug Lite 1.3.2";
8-
var extensionURL = chrome.extension.getURL("");
9-
var isActive = false;
10-
11-
// *************************************************************************************************
12-
13-
function handleIconClick(tab)
14-
{
15-
if (tab.url.indexOf("https://chrome.google.com/extensions") == 0 ||
16-
tab.url.indexOf("chrome://") == 0)
17-
{
18-
alert("For security reasons extensions cannot run content scripts at this page, and therefore, Firebug Lite can't work here.");
19-
20-
return;
21-
}
22-
23-
var isContentScriptActive = false;
24-
25-
chrome.tabs.sendRequest( tab.id, {name: "FB_isActive"},
26-
27-
function(response)
28-
{
29-
isContentScriptActive = true;
30-
31-
if (response.value == "true")
32-
{
33-
chrome.tabs.update(tab.id, {url: "javascript:Firebug.chrome.toggle()"});
34-
}
35-
else
36-
{
37-
setActivationStorage(tab);
38-
chrome.tabs.sendRequest(tab.id, {name: "FB_loadFirebug"});
39-
}
40-
}
41-
);
42-
/*
43-
setTimeout(function(){
44-
45-
if (!isContentScriptActive)
46-
{
47-
//chrome.tabs.update(tab.id, {url: bookmarlet});
48-
//enableBrowserActionIcon();
49-
//setActivationStorage(tab);
50-
51-
//alert("Firebug Lite can't open because this page was open before it was installed. Please reload this page.");
52-
53-
setActivationStorage(tab);
54-
if (confirm("Firebug Lite can't complete its activation because this page was open before the extension itself was enabled. The process will complete when you reload the page.\n\nPress ok to reload the page now, or cancel to reload it later."))
55-
{
56-
chrome.tabs.update(tab.id, {url: "javascript:window.location.reload()"});
57-
}
58-
}
59-
60-
},500);/**/
61-
};
62-
63-
chrome.browserAction.onClicked.addListener(handleIconClick);
64-
65-
// *************************************************************************************************
66-
67-
function handleTabChange(tabId, selectInfo)
68-
{
69-
var isUpdated = false;
70-
71-
chrome.tabs.sendRequest(tabId, {name: "FB_isActive"},
72-
73-
function(response)
74-
{
75-
isUpdated = true;
76-
77-
if (response.value == "true")
78-
{
79-
enableBrowserActionIcon();
80-
isActive = true;
81-
}
82-
else
83-
{
84-
disableBrowserActionIcon();
85-
isActive = false;
86-
}
87-
}
88-
);
89-
90-
setTimeout(function(){
91-
92-
chrome.tabs.get(tabId, function(tab){
93-
94-
var title = tab.title || "";
95-
if (!isUpdated && !title.indexOf("Firebug Lite") == 0)
96-
{
97-
disableBrowserActionIcon();
98-
isActive = false;
99-
}
100-
101-
});
102-
103-
},100);
104-
};
105-
106-
// *************************************************************************************************
107-
108-
chrome.tabs.onSelectionChanged.addListener(handleTabChange);
109-
110-
// *************************************************************************************************
111-
112-
function handleUpdateTab(tabId, updateInfo, tab)
113-
{
114-
if (updateInfo.status == "complete") return;
115-
116-
handleTabChange(tabId, updateInfo);
117-
}
118-
119-
// memory leaking here
120-
//chrome.tabs.onUpdated.addListener(handleUpdateTab);
121-
122-
// *************************************************************************************************
123-
124-
chrome.extension.onRequest.addListener
125-
(
126-
function(request, sender, sendResponse)
127-
{
128-
if (request.name == "FB_enableIcon")
129-
enableBrowserActionIcon();
130-
131-
else if (request.name == "FB_disableIcon")
132-
disableBrowserActionIcon();
133-
134-
else if (request.name == "FB_deactivate")
135-
{
136-
disableBrowserActionIcon();
137-
chrome.tabs.getSelected(null, function(tab){
138-
unsetActivationStorage(tab);
139-
140-
chrome.tabs.sendRequest(tab.id, {name: "FB_deactivate"});
141-
});
142-
}
143-
144-
sendResponse({}); // snub them.
145-
}
146-
);
147-
148-
// *************************************************************************************************
149-
150-
chrome.contextMenus.create({
151-
title: "Inspect with Firebug Lite",
152-
"contexts": ["all"],
153-
onclick: function(info, tab) {
154-
chrome.tabs.sendRequest(tab.id, {name: "FB_contextMenuClick"});
155-
}
156-
});
157-
158-
// *************************************************************************************************
159-
160-
function enableBrowserActionIcon()
161-
{
162-
chrome.browserAction.setTitle({title: firebugVersion + " (On)"});
163-
chrome.browserAction.setIcon({path:"firebug24.png"});
164-
};
165-
166-
function disableBrowserActionIcon()
167-
{
168-
chrome.browserAction.setTitle({title: firebugVersion + " (Off)"});
169-
chrome.browserAction.setIcon({path:"firebug24_disabled.png"});
170-
};
171-
172-
// *************************************************************************************************
173-
174-
function setActivationStorage(tab)
175-
{
176-
chrome.tabs.update(tab.id, {url: "javascript:localStorage.setItem('Firebug','1,1,"+extensionURL+"')"});
177-
isActive = true;
178-
};
179-
180-
function unsetActivationStorage(tab)
181-
{
182-
chrome.tabs.update(tab.id, {url: "javascript:localStorage.removeItem('Firebug')"});
183-
isActive = false;
184-
};
185-
186-
// *************************************************************************************************
187-
</script>
1+
<html>
2+
<body>
3+
<script src="background.js"></script>
4+
</body>
5+
</html>
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/* See license.txt for terms of usage */
2+
3+
// *************************************************************************************************
4+
5+
//var bookmarlet = "javascript:(typeof Firebug!='undefined')?Firebug.chrome.toggle():(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E=F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLiteBookmarlet','1.3.0.1','firebug.jgz','skin/xp/sprite.png','https://getfirebug.com/releases/lite/beta/','#startOpened,showIconWhenHidden=false');";
6+
var firebugVersion = "Firebug Lite 1.3.2";
7+
var extensionURL = chrome.extension.getURL("");
8+
var isActive = false;
9+
10+
// *************************************************************************************************
11+
12+
function handleIconClick(tab)
13+
{
14+
if (tab.url.indexOf("https://chrome.google.com/extensions") == 0 ||
15+
tab.url.indexOf("chrome://") == 0)
16+
{
17+
alert("For security reasons extensions cannot run content scripts at this page, and therefore, Firebug Lite can't work here.");
18+
19+
return;
20+
}
21+
22+
var isContentScriptActive = false;
23+
24+
chrome.tabs.sendMessage( tab.id, {name: "FB_isActive"},
25+
26+
function(response)
27+
{
28+
isContentScriptActive = true;
29+
30+
if (response.value == "true")
31+
{
32+
chrome.tabs.update(tab.id, {url: "javascript:Firebug.chrome.toggle()"});
33+
}
34+
else
35+
{
36+
setActivationStorage(tab);
37+
chrome.tabs.sendMessage(tab.id, {name: "FB_loadFirebug"});
38+
}
39+
}
40+
);
41+
/*
42+
setTimeout(function(){
43+
44+
if (!isContentScriptActive)
45+
{
46+
//chrome.tabs.update(tab.id, {url: bookmarlet});
47+
//enableBrowserActionIcon();
48+
//setActivationStorage(tab);
49+
50+
//alert("Firebug Lite can't open because this page was open before it was installed. Please reload this page.");
51+
52+
setActivationStorage(tab);
53+
if (confirm("Firebug Lite can't complete its activation because this page was open before the extension itself was enabled. The process will complete when you reload the page.\n\nPress ok to reload the page now, or cancel to reload it later."))
54+
{
55+
chrome.tabs.update(tab.id, {url: "javascript:window.location.reload()"});
56+
}
57+
}
58+
59+
},500);/**/
60+
};
61+
62+
chrome.browserAction.onClicked.addListener(handleIconClick);
63+
64+
// *************************************************************************************************
65+
66+
function handleTabChange(tabId, selectInfo)
67+
{
68+
var isUpdated = false;
69+
70+
chrome.tabs.sendMessage(tabId, {name: "FB_isActive"},
71+
72+
function(response)
73+
{
74+
isUpdated = true;
75+
76+
if (response.value == "true")
77+
{
78+
enableBrowserActionIcon();
79+
isActive = true;
80+
}
81+
else
82+
{
83+
disableBrowserActionIcon();
84+
isActive = false;
85+
}
86+
}
87+
);
88+
89+
setTimeout(function(){
90+
91+
chrome.tabs.get(tabId, function(tab){
92+
93+
var title = tab.title || "";
94+
if (!isUpdated && !title.indexOf("Firebug Lite") == 0)
95+
{
96+
disableBrowserActionIcon();
97+
isActive = false;
98+
}
99+
100+
});
101+
102+
},100);
103+
};
104+
105+
// *************************************************************************************************
106+
107+
chrome.tabs.onSelectionChanged.addListener(handleTabChange);
108+
109+
// *************************************************************************************************
110+
111+
function handleUpdateTab(tabId, updateInfo, tab)
112+
{
113+
if (updateInfo.status == "complete") return;
114+
115+
handleTabChange(tabId, updateInfo);
116+
}
117+
118+
// memory leaking here
119+
//chrome.tabs.onUpdated.addListener(handleUpdateTab);
120+
121+
// *************************************************************************************************
122+
123+
chrome.runtime.onMessage.addListener
124+
(
125+
function(request, sender, sendResponse)
126+
{
127+
if (request.name == "FB_enableIcon")
128+
enableBrowserActionIcon();
129+
130+
else if (request.name == "FB_disableIcon")
131+
disableBrowserActionIcon();
132+
133+
else if (request.name == "FB_deactivate")
134+
{
135+
disableBrowserActionIcon();
136+
chrome.tabs.query({currentWindow: true}, function(tab){
137+
unsetActivationStorage(tab[0].id);
138+
139+
chrome.tabs.sendMessage(tab[0].id, {name: "FB_deactivate"});
140+
});
141+
}
142+
143+
sendResponse({}); // snub them.
144+
}
145+
);
146+
147+
// *************************************************************************************************
148+
149+
chrome.contextMenus.create({
150+
title: "Inspect with Firebug Lite",
151+
"contexts": ["all"],
152+
onclick: function(info, tab) {
153+
chrome.tabs.query({currentWindow: true}, function(tabs) {
154+
chrome.tabs.sendMessage(tabs[0].id, {name: "FB_contextMenuClick"});
155+
});
156+
}
157+
});
158+
159+
// *************************************************************************************************
160+
161+
function enableBrowserActionIcon()
162+
{
163+
chrome.browserAction.setTitle({title: firebugVersion + " (On)"});
164+
chrome.browserAction.setIcon({path:"firebug24.png"});
165+
};
166+
167+
function disableBrowserActionIcon()
168+
{
169+
chrome.browserAction.setTitle({title: firebugVersion + " (Off)"});
170+
chrome.browserAction.setIcon({path:"firebug24_disabled.png"});
171+
};
172+
173+
// *************************************************************************************************
174+
175+
function setActivationStorage(tab)
176+
{
177+
chrome.tabs.update(tab.id, {url: "javascript:localStorage.setItem('Firebug','1,1,"+extensionURL+"')"});
178+
isActive = true;
179+
};
180+
181+
function unsetActivationStorage(tab)
182+
{
183+
chrome.tabs.update(tab.id, {url: "javascript:localStorage.removeItem('Firebug')"});
184+
isActive = false;
185+
};
186+
187+
// *************************************************************************************************

0 commit comments

Comments
 (0)