-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
37 lines (33 loc) · 1.17 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
28
29
30
31
32
33
34
35
36
37
// Inject after page loads
window.addEventListener('load', () => {
// Only run on product pages (URL contains "/dp/")
if (window.location.href.includes('/dp/')) {
// Create the button
const couponButton = document.createElement('button');
couponButton.textContent = '🚀 Claim Coupons (Free!)';
couponButton.style.cssText = `
background: #FF9900;
color: white;
padding: 12px;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: bold;
margin: 15px 0;
`;
// Add affiliate link logic
couponButton.onclick = () => {
const currentUrl = new URL(window.location.href);
// Add YOUR AFFILIATE TAG
currentUrl.searchParams.set('tag', 'couponcatch0a-20'); // Your ID here
// Redirect to Amazon's coupon section for this product
window.location.href = `${currentUrl.toString()}#promotions`;
};
// Insert near the price/buy box
const buyBox = document.getElementById('buybox') ||
document.querySelector('[data-feature-name="buybox"]');
if (buyBox) {
buyBox.prepend(couponButton);
}
}
});