-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
27 lines (21 loc) · 1.06 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
console.log("Content script loaded");
function getStockData() {
const stockNameElement = document.querySelector('.title-l31H9iuA'); // Select the first element with this class
const stockPriceElement = document.querySelector('.buttonText-hw_3o_pb'); // Select the first element with this class
console.log('stockNameElement:', stockNameElement); // Debugging log
console.log('stockPriceElement:', stockPriceElement); // Debugging log
if (stockNameElement && stockPriceElement) {
const stockName = stockNameElement.textContent;
const stockPrice = stockPriceElement.textContent;
return { stockName, stockPrice };
}
return { stockName: 'N/A', stockPrice: 'N/A' };
}
// chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// console.log('Received message:', request); // Debugging log
// if (request.message === 'getStockData') {
// const stockData = getStockData();
// console.log('Sending stock data:', stockData); // Debugging log
// sendResponse(stockData);
// }
// });