Advertisement
Guest User

Code help

a guest
Mar 2nd, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. console.log('Content script loaded.');
  2.  
  3. // Get the list of sports team names
  4. const PhoneType = ["iPhone", "Samsung", "Google"];
  5.  
  6. // Loop through each email in the inbox
  7. const emails = document.querySelectorAll('[role="listitem"]');
  8. for (let i = 0; i < emails.length; i++) {
  9. const email = emails[i];
  10.  
  11. // Add an event listener to each email
  12. email.addEventListener('click', function() {
  13. console.log('Searching for phone names...');
  14.  
  15. // Check if the email contains any phone type names
  16. const emailText = email.textContent;
  17. for (let j = 0; j < PhoneType.length; j++) {
  18. const PhoneType = PhoneType[j];
  19. if (emailText.includes(PhoneType)) {
  20. console.log(`Notification for ${PhoneType} is being sent.`);
  21.  
  22. // Send a notification with a link to the ticketing site
  23. const options = {
  24. type: "basic",
  25. title: "Phone Link Notification",
  26. message: `Inventory for ${PhoneType} is now available!`,
  27. iconUrl: "icon.png",
  28. buttons: [
  29. { title: "Buy Phone", iconUrl: "buy_phone.png" }
  30. ]
  31. };
  32. chrome.notifications.create(options, function(notificationId) {
  33. // Add an event listener to open the phone site URL when the notification button is clicked
  34. chrome.notifications.onButtonClicked.addListener(function(clickedNotificationId, buttonIndex) {
  35. if (clickedNotificationId === notificationId && buttonIndex === 0) {
  36. window.open("https://www.apple.com/");
  37. }
  38. });
  39. });
  40.  
  41. break;
  42. }
  43. }
  44. });
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement