Commit e637539d authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Transform into a web extension

parent 1036ffc49005
......@@ -27,6 +27,11 @@ function getTabData(id) {
return allTabs[id];
}
function updateTab(tabId) {
updateIcon(tabId);
chrome.tabs.sendMessage(tabId, getTabData(tabId));
}
function updateIcon(tabId) {
data = getTabData(tabId);
chrome.browserAction.setIcon({
......@@ -50,13 +55,13 @@ function updateIcon(tabId) {
function toggleActive(tab) {
data = getTabData(tab.id);
data.isActive = !data.isActive;
updateIcon(tab.id);
updateTab(tab.id);
}
chrome.browserAction.onClicked.addListener(toggleActive);
function onTabActivated(tabId) {
updateIcon(tabId);
updateTab(tabId);
}
// listen to tab URL changes
......@@ -154,13 +159,13 @@ function onHeadersReceived(details) {
data.linkedData = detectDataOnContent(details.tabId, details.responseHeaders);
if (data.linkedData == NO_DATA)
data.linkedData = detectDataOnLinks(details.responseHeaders);
updateIcon(details.tabId);
updateTab(details.tabId);
}
function onBeforeNavigate(details) {
data = getTabData(details.tabId);
data.linkedData = NO_DATA;
updateIcon(details.tabId);
updateTab(details.tabId);
}
// listen to received headers
......
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
console.log(request);
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment