Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. // Called when the url of a tab changes.
  2. // So we can notify users
  3. var notification = webkitNotifications.createNotification(
  4. '48.png',
  5. 'Alert!'
  6. );
  7. // Called when the url of a tab changes.
  8. function checkForValidUrl(tab) {
  9. // Compare with a the URL
  10. if (tab.url.match(/google/)) {
  11. //then
  12. notification.show();
  13. }
  14. };
  15. // Listen for any changes to the URL of any tab.
  16. chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
  17. if(changeInfo.status == "loading") {
  18. checkForValidUrl(tab);
  19. }
  20. });
  21.  
  22. chrome.tabs.onSelectionChanged.addListener(function(tabId, selectInfo){
  23. chrome.tabs.getSelected(null, function(tab){
  24. checkForValidUrl(tab);
  25. });
  26. });
  27.  
  28. function checkForValidUrl(tabId, changeInfo, tab) {
  29.  
  30. var notification = webkitNotifications.createNotification(
  31. '48.png',
  32. 'Alert!',
  33. 'Watch out for your privacy!'
  34. );
  35.  
  36. // Compare with the URL
  37. if (tab.url.match(/google/)) {
  38. //then
  39. notification.show();
  40. }
  41. };
  42.  
  43. chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
  44. if(changeInfo.status == "loading") {
  45. checkForValidUrl(tabId, changeInfo, tab);
  46. }
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement