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

Transform into a web extension

parent c0726d0a49e4
{
"manifest_version": 2,
"name": "Linked Data Browser",
"version": "0.2",
"description": "A browser for the web of data.",
"icons": {
"48": "icons/browser_action.png"
},
"permissions": [
"tabs",
"activeTab"
],
"browser_action": {
"default_icon": "icons/browser_action_disabled.png",
"default_title": "Linked Data Browser"
},
"content_scripts": [
{
"matches": [
"*://*/*"
],
"js": [
"src/content/main.js"
]
}
],
"background": {
"scripts": [
"src/background/main.js"
]
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
"name": "cubicweb-generic-client",
"version": "0.1.0",
"scripts": {
"build": "bsb -make-world",
"build": "bsb -clean-world && bsb -make-world && webpack",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world",
"test": "echo \"Error: no test specified\" && exit 1",
......@@ -25,9 +25,10 @@
},
"devDependencies": {
"bs-platform": "^3.1.5",
"html-webpack-plugin": "^3.0.0",
"web-ext": "^2.7.0",
"webpack": "^4.0.1",
"webpack-cli": "^2.0.10",
"webpack-dev-server": "^3.0.0",
"html-webpack-plugin": "^3.0.0"
"webpack-dev-server": "^3.0.0"
}
}
var currentTab;
var allTabs = {};
function updateIcon() {
chrome.browserAction.setIcon({
path: allTabs[currentTab.id] ? {
48: "icons/browser_action.png"
} : {
48: "icons/browser_action_disabled.png"
},
tabId: currentTab.id
});
}
function toggleActive() {
allTabs[currentTab.id] = !allTabs[currentTab.id];
updateIcon();
}
chrome.browserAction.onClicked.addListener(toggleActive);
function updateActiveTab(tabs) {
function updateTab(tabs) {
if (tabs[0]) {
currentTab = tabs[0];
if (!allTabs.hasOwnProperty(currentTab.id)) {
allTabs[currentTab.id] = false;
}
}
}
var gettingActiveTab = chrome.tabs.query({ active: true, currentWindow: true }, updateTab);
if (gettingActiveTab != null) {
gettingActiveTab.then(updateTab);
}
}
// listen to tab URL changes
chrome.tabs.onUpdated.addListener(updateActiveTab);
// listen to tab switching
chrome.tabs.onActivated.addListener(updateActiveTab);
// listen for window switching
chrome.windows.onFocusChanged.addListener(updateActiveTab);
// update when the extension loads initially
updateActiveTab();
\ 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