Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
SemWeb
libview
Commits
acaf2f111ba0
Commit
e637539d
authored
Jul 06, 2018
by
Laurent Wouters
Browse files
Transform into a web extension
parent
1036ffc49005
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/background/main.js
View file @
acaf2f11
...
...
@@ -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
;
update
Icon
(
tab
.
id
);
update
Tab
(
tab
.
id
);
}
chrome
.
browserAction
.
onClicked
.
addListener
(
toggleActive
);
function
onTabActivated
(
tabId
)
{
update
Icon
(
tabId
);
update
Tab
(
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
);
update
Icon
(
details
.
tabId
);
update
Tab
(
details
.
tabId
);
}
function
onBeforeNavigate
(
details
)
{
data
=
getTabData
(
details
.
tabId
);
data
.
linkedData
=
NO_DATA
;
update
Icon
(
details
.
tabId
);
update
Tab
(
details
.
tabId
);
}
// listen to received headers
...
...
src/content/main.js
View file @
acaf2f11
chrome
.
runtime
.
onMessage
.
addListener
(
function
(
request
,
sender
,
sendResponse
)
{
console
.
log
(
request
);
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment