-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
27 lines (22 loc) · 883 Bytes
/
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 is running");
function getGameTitle() {
// Try Prime Gaming specific title format first
const title = document.querySelector("title")?.innerText || '';
const primeMatch = title.match(/Prime Gaming - (.+)/);
if (primeMatch) return primeMatch[1];
// Try Amazon Gaming page format
const gameTitle = document.querySelector('h1')?.innerText || '';
if (gameTitle) return gameTitle;
// Try product title format
const productTitle = document.querySelector('#productTitle')?.innerText?.trim() || '';
if (productTitle) return productTitle;
return null;
}
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "getTitle") {
const title = getGameTitle();
console.log("Found game title:", title);
sendResponse({ title });
}
return true;
});