Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Seniors
craig1617
Commits
bf451921
Commit
bf451921
authored
Nov 29, 2016
by
Craig Earley
Browse files
extension now enthusiastically alerts you when you visit the google dot com
parent
a8da1f14
Changes
2
Hide whitespace changes
Inline
Side-by-side
extension/js/background.js
View file @
bf451921
var
debug
=
0
;
var
stop_url
=
"
https://www.google.com/
"
chrome
.
tabs
.
onUpdated
.
addListener
(
function
(
tabID
,
changeInfo
,
tab
)
{
var
url
;
chrome
.
tabs
.
query
({
'
active
'
:
true
,
'
lastFocusedWindow
'
:
true
},
function
(
tabs
)
{
url
=
tabs
[
0
].
url
;
if
(
debug
){
console
.
log
(
url
);}
if
(
changeInfo
.
status
==
'
complete
'
){
chrome
.
tabs
.
sendMessage
(
tab
.
id
,
{
action
:
'
saySomething
'
});
}
});
if
(
url
==
stop_url
){
chrome
.
tabs
.
sendMessage
(
tab
.
id
,
{
action
:
'
saySomething
'
});
if
(
debug
)
{
console
.
log
(
"
background something
"
);}}
}
});});
extension/js/content.js
View file @
bf451921
chrome
.
runtime
.
onMessage
.
addListener
(
function
(
msg
)
{
/* We received a message, let's do as instructed */
if
(
msg
.
action
==
'
saySomething
'
)
{
window
.
alert
(
'
something
'
);
window
.
alert
(
'
Google!
'
);
}
});
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