forked from Josephine-Chen/FocusPro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53067fa
commit 98e6f43
Showing
5 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Called when the user clicks on the browser action. | ||
chrome.browserAction.onClicked.addListener(function(tab) { | ||
// Send a message to the active tab | ||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { | ||
var activeTab = tabs[0]; | ||
chrome.tabs.sendMessage(activeTab.id, {"message": "clicked_browser_action"}); | ||
}); | ||
}); | ||
|
||
// This block is new! | ||
chrome.runtime.onMessage.addListener( | ||
function(request, sender, sendResponse) { | ||
if( request.message === "open_new_tab" ) { | ||
chrome.tabs.create({"url": request.url}); | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
chrome.runtime.onMessage.addListener( | ||
function(request, sender, sendResponse) { | ||
if( request.message === "clicked_browser_action" ) { | ||
var firstHref = $("a[href^='http']").eq(0).attr("href"); | ||
|
||
//This is site url | ||
console.log(firstHref); | ||
var focusProURL = 'https://focuspro.herokuapp.com/'; | ||
chrome.runtime.sendMessage({"message": "open_new_tab", "url": focusProURL}); | ||
} | ||
} | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//Tutorial: https://robots.thoughtbot.com/how-to-make-a-chrome-extension | ||
{ | ||
"manifest_version": 2, | ||
"name": "FocusPro Extension", | ||
"version": "0.1", | ||
"background": { | ||
"scripts": ["background.js"] | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": [ | ||
"<all_urls>" | ||
], | ||
"js": ["jquery-3.1.1.min.js", "content.js"] | ||
} | ||
], | ||
"browser_action": { | ||
"default_icon": "icon.png" | ||
} | ||
} |