Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log('Content script loaded.');
- // Get the list of sports team names
- const PhoneType = ["iPhone", "Samsung", "Google"];
- // Loop through each email in the inbox
- const emails = document.querySelectorAll('[role="listitem"]');
- for (let i = 0; i < emails.length; i++) {
- const email = emails[i];
- // Add an event listener to each email
- email.addEventListener('click', function() {
- console.log('Searching for phone names...');
- // Check if the email contains any phone type names
- const emailText = email.textContent;
- for (let j = 0; j < PhoneType.length; j++) {
- const PhoneType = PhoneType[j];
- if (emailText.includes(PhoneType)) {
- console.log(`Notification for ${PhoneType} is being sent.`);
- // Send a notification with a link to the ticketing site
- const options = {
- type: "basic",
- title: "Phone Link Notification",
- message: `Inventory for ${PhoneType} is now available!`,
- iconUrl: "icon.png",
- buttons: [
- { title: "Buy Phone", iconUrl: "buy_phone.png" }
- ]
- };
- chrome.notifications.create(options, function(notificationId) {
- // Add an event listener to open the phone site URL when the notification button is clicked
- chrome.notifications.onButtonClicked.addListener(function(clickedNotificationId, buttonIndex) {
- if (clickedNotificationId === notificationId && buttonIndex === 0) {
- window.open("https://www.apple.com/");
- }
- });
- });
- break;
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement