-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First step towards providing users with more feedback about the SRM check performed (e.g. #5 and/or #6). I find it strange that I needed to add browser_action for this, but there seems to be no way around this. I don't think this actually gives the extension more permissions, but documentation is a bit unclear.
- Loading branch information
1 parent
df121e9
commit 934d367
Showing
4 changed files
with
50 additions
and
11 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 |
---|---|---|
@@ -1,18 +1,43 @@ | ||
// Send message to content.js when URL changes | ||
chrome.tabs.onUpdated.addListener(function | ||
(tabId, changeInfo, tab) { | ||
(tabId, changeInfo, tab) { | ||
if (changeInfo.url) { | ||
chrome.tabs.sendMessage(tabId, { | ||
message: 'URL has changed', | ||
url: changeInfo.url | ||
}) | ||
chrome.tabs.sendMessage(tabId, { | ||
message: 'URL has changed', | ||
url: changeInfo.url | ||
}) | ||
} | ||
}); | ||
}); | ||
|
||
chrome.runtime.onInstalled.addListener(function(details) { | ||
if (details.reason == "install") { | ||
if (chrome.runtime.setUninstallURL) { | ||
chrome.runtime.setUninstallURL('https://forms.gle/Cgv34WVhgms9MChv7'); | ||
} | ||
if (details.reason == "install") { | ||
if (chrome.runtime.setUninstallURL) { | ||
chrome.runtime.setUninstallURL('https://forms.gle/Cgv34WVhgms9MChv7'); | ||
} | ||
} | ||
}); | ||
|
||
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { | ||
console.log(message); | ||
if (message.badgeBackgroundColor) { | ||
chrome.browserAction.setBadgeBackgroundColor({color: message.badgeBackgroundColor}); | ||
} | ||
if (message.badgeText) { | ||
chrome.tabs.get(sender.tab.id, function(tab) { | ||
if (chrome.runtime.lastError) { | ||
return; // the prerendered tab has been nuked, happens in omnibox search | ||
} | ||
if (tab.index >= 0) { // tab is visible | ||
chrome.browserAction.setBadgeText({tabId:tab.id, text:message.badgeText}); | ||
} else { // prerendered tab, invisible yet, happens quite rarely | ||
var tabId = sender.tab.id, text = message.badgeText; | ||
chrome.webNavigation.onCommitted.addListener(function update(details) { | ||
if (details.tabId == tabId) { | ||
chrome.browserAction.setBadgeText({tabId: tabId, text: text}); | ||
chrome.webNavigation.onCommitted.removeListener(update); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); |
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
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
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