Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Called when the url of a tab changes.
- // So we can notify users
- var notification = webkitNotifications.createNotification(
- '48.png',
- 'Alert!'
- );
- // Called when the url of a tab changes.
- function checkForValidUrl(tab) {
- // Compare with a the URL
- if (tab.url.match(/google/)) {
- //then
- notification.show();
- }
- };
- // Listen for any changes to the URL of any tab.
- chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
- if(changeInfo.status == "loading") {
- checkForValidUrl(tab);
- }
- });
- chrome.tabs.onSelectionChanged.addListener(function(tabId, selectInfo){
- chrome.tabs.getSelected(null, function(tab){
- checkForValidUrl(tab);
- });
- });
- function checkForValidUrl(tabId, changeInfo, tab) {
- var notification = webkitNotifications.createNotification(
- '48.png',
- 'Alert!',
- 'Watch out for your privacy!'
- );
- // Compare with the URL
- if (tab.url.match(/google/)) {
- //then
- notification.show();
- }
- };
- chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
- if(changeInfo.status == "loading") {
- checkForValidUrl(tabId, changeInfo, tab);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement