-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
20 lines (18 loc) · 882 Bytes
/
Copy pathbackground.js
File metadata and controls
20 lines (18 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// On a request (from the content script), show the page action icon for the
// tab that the sender (content script) was on
function onRequest(request, sender, callback) {
chrome.pageAction.show(sender.tab.id);
callback({});
};
// Listen for the content script to send a message to the background page.
chrome.extension.onMessage.addListener(onRequest);
// For pushstate updates, notify the content script
chrome.webNavigation.onHistoryStateUpdated.addListener(function (details) {
if (details.url.match(/^https*:\/\/www\.facebook\.com\/*$/) || details.url.match(/^https*:\/\/www\.facebook\.com\/\?/)) {
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { event: "onHistoryStateUpdated", details }, function (response) {
console.log(response.farewell);
});
});
}
});