10 Best Bulbs for Pot Lights in 2026 – Expert Tested Picks

If you are shopping for the best bulbs for pot lights, you probably want three things: soft light, easy dimming, and a bulb that does not burn out too fast. Pot lights can make a room feel cozy or harsh depending on the bulb, so the right pick really matters. In this roundup, I focused on BR30-style LED bulbs that fit recessed cans well and work for everyday home use.

Contents

Quick Product Comparison

.modern-product-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
font-size: 14px;
}
.modern-product-table thead th {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 10px 8px;
text-align: left;
font-weight: 600;
font-size: 15px;
border: none;
}
.modern-product-table tbody td {
padding: 10px 8px;
border-bottom: 1px solid #f0f0f0;
vertical-align: middle;
}
.modern-product-table tbody tr:last-child td {
border-bottom: none;
}
.product-name {
font-weight: 600;
color: #2d3748;
font-size: 14px;
line-height: 1.4;
max-width: 300px;
}
.product-name a {
color: inherit;
text-decoration: none;
}
.product-name a:hover {
color: #ff6b35 !important;
}
.product-image-cell {
text-align: center;
width: 80px;
}
.product-image-cell img {
width: 60px;
height: 60px;
object-fit: cover;
border-radius: 8px;
border: 2px solid #e2e8f0;
transition: transform 0.2s ease;
}
.product-image-cell img:hover {
transform: scale(1.05);
}
.price-button-cell {
text-align: center;
width: 140px;
}
.price-button {
display: inline-block;
background: linear-gradient(135deg, #ff9900 0%, #ff6b35 100%);
color: white;
padding: 8px 12px;
text-decoration: none !important;
border-radius: 6px;
font-weight: 600;
font-size: 13px;
box-shadow: 0 2px 8px rgba(255,153,0,0.3);
transition: all 0.2s ease;
white-space: nowrap;
}
.price-button:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(255,153,0,0.4);
}
@media (max-width: 768px) {
.modern-product-table {
font-size: 13px;
}
.modern-product-table thead th {
padding: 8px 6px;
font-size: 14px;
}
.modern-product-table tbody td {
padding: 8px 6px;
}
.product-name {
font-size: 13px;
max-width: 200px;
}
.product-image-cell img {
width: 50px;
height: 50px;
}
.price-button {
padding: 6px 10px;
font-size: 12px;
}
}
@media (max-width: 480px) {
.modern-product-table {
font-size: 12px;
}
.modern-product-table thead th {
padding: 6px 4px;
font-size: 13px;
}
.modern-product-table tbody td {
padding: 6px 4px;
}
.product-name {
font-size: 12px;
max-width: 150px;
}
.product-image-cell {
width: 60px;
}
.product-image-cell img {
width: 40px;
height: 40px;
}
.price-button-cell {
width: 120px;
}
.price-button {
padding: 5px 8px;
font-size: 11px;
}
}

Product Image Check Price
1. Sunco BR30 LED Bulbs Sunco BR30 LED Bulbs, 12-Pack Dimmable Recessed Flood Lights, 3000K Wa Check Price
2. Amazon Basics BR30 LED Bulbs Amazon Basics BR30 LED Light Bulbs, 65W Equivalent, Dimmable, Soft Whi Check Price
3. TJOY BR30 LED Bulbs TJOY BR30 LED Flood Bulbs, 12-Pack Dimmable Recessed Lights, 2700K Sof Check Price
4. SYLVANIA ECO BR30 LED Bulb SYLVANIA ECO BR30 LED Bulb, Dimmable Soft White 2700K, 4-Pack Check Price
5. Feit Electric BR30 LED Bulb Feit Electric BR30 LED Flood Bulbs, Dimmable 5CCT Adjustable White, 6- Check Price
6. DEGNJU BR30 LED Bulb DEGNJU BR30 LED Recessed Light Bulbs, 12-Pack Dimmable Soft White, E26 Check Price
7. Sigalux BR30 LED Bulbs Sigalux BR30 LED Flood Bulbs, 12-Pack Dimmable Soft White 2700K, E26 B Check Price
8. Sigalux BR30 LED Bulbs Sigalux BR30 LED Flood Bulbs, 6-Pack Dimmable Soft White 2700K, E26 Ba Check Price
9. DEGNJU BR30 LED Bulb DEGNJU BR30 LED Bulb, 6-Pack Dimmable Recessed Flood Lights, 2700K Sof Check Price
10. MASTERY MART BR30 LED Bulb MASTERY MART BR30 LED Light Bulbs, 12-Pack Dimmable Daylight 5000K, E2 Check Price

Our Top 10 Best Bulbs For Pot Lights Reviews – Expert Tested & Recommended

🏆 Best Choice


h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

1. Sunco BR30 LED Bulbs, 12-Pack Dimmable Recessed Flood Lights, 3000K Warm White, E26 Base

Sunco BR30 LED Bulbs, 12-Pack Dimmable Recessed Flood Lights, 3000K Warm White, E26 Base

The Sunco BR30 LED Bulbs are the kind of pot light bulbs that make a room feel calm right away. The warm 3000K tone works well in bedrooms, kitchens, and living rooms, and the dimming range helps you keep things soft at night or brighter during the day.

Key Features That Stand Out

  • ✓ Dimmable from 10% to 100% for flexible lighting control
  • ✓ Warm 3000K color gives a cozy, natural look
  • ✓ Fits standard 5-inch and 6-inch recessed cans
  • ✓ E26 base makes installation simple for most homes
  • ✓ Designed for good color rendering in everyday spaces

Why We Recommend It

This is an easy pick if you want a safe, familiar light color that works in most rooms. It does not try to be fancy, and that is part of the appeal. If you want one of the best bulbs for pot lights with broad everyday use, this is a strong place to start.

Best For

Best for homeowners who want a warm, balanced light for general room lighting. It is also a smart choice if you are replacing older recessed bulbs in several rooms at once.

Pros and Cons

Pros:
  • Warm, comfortable light that feels easy on the eyes
  • Wide dimming range for different moods
  • Good fit for common recessed can sizes
  • 12-pack offers solid value for larger projects
Cons:
  • Not ideal if you want a very bright daylight look
  • May feel a little soft for task-heavy work areas
  • No adjustable color temperature

Customer Reviews

Customer Review: “Great warm light for our living room. They dim smoothly and made the space feel much more comfortable.”

Customer Review: “Easy to install and the color is just right. I used them in recessed cans in the hallway and kitchen.”

⭐ Editor’s Choice


h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

2. Amazon Basics BR30 LED Light Bulbs, 65W Equivalent, Dimmable, Soft White 2700K, 6-Pack

Amazon Basics BR30 LED Light Bulbs, 65W Equivalent, Dimmable, Soft White 2700K, 6-Pack

Amazon Basics BR30 LED Light Bulbs are a simple, practical choice for pot lights. They keep the light soft at 2700K and use far less energy than old incandescent bulbs, which is nice if you are replacing a bunch of recessed lights at once.

Key Features That Stand Out

  • ✓ 65W equivalent output with only 11W of power use
  • ✓ Soft white 2700K color for relaxed indoor lighting
  • ✓ Dimmable design for bedrooms, hallways, and family rooms
  • ✓ E26 standard base for easy compatibility
  • ✓ Long lifespan helps reduce replacement hassle

Why We Recommend It

This is one of the easiest bulbs to recommend if you want dependable lighting without much guesswork. The light is soft, the performance is steady, and the price tends to stay friendly. If you are comparing the best bulbs for pot lights on value alone, this one belongs near the top.

Best For

Best for renters, first-time homeowners, and anyone who wants a no-drama bulb for general recessed lighting. It also works well if you prefer a softer glow over a bright white look.

Pros and Cons

Pros:
  • Very efficient compared with old incandescent bulbs
  • Soft white tone is easy to live with
  • Good option for whole-home replacement projects
  • Simple, familiar design
Cons:
  • Not the brightest option in this roundup
  • Only one color temperature
  • May be too warm for workspaces

Customer Reviews

Customer Review: “These were exactly what I needed for the kitchen recessed lights. Soft, clean light and no weird flicker.”

Customer Review: “Good value pack and easy to swap in. They make the room feel warm without being too yellow.”

💰 Best Budget


h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

3. TJOY BR30 LED Flood Bulbs, 12-Pack Dimmable Recessed Lights, 2700K Soft White, E26 Base

TJOY BR30 LED Flood Bulbs, 12-Pack Dimmable Recessed Lights, 2700K Soft White, E26 Base

The TJOY BR30 LED Flood Bulbs are a nice budget-friendly pick for recessed lighting. They aim for a warm, comfortable look and keep energy use low, which makes them a good fit for bigger rooms or multi-bulb setups.

Key Features That Stand Out

  • ✓ 10% to 100% dimming for flexible room lighting
  • ✓ 2700K soft white tone for a cozy feel
  • ✓ 9W energy use with 65W-style brightness
  • ✓ CRI 80+ for decent color appearance
  • ✓ FCC compliant and eye-friendly design

Why We Recommend It

This is a strong budget option if you want a full pack without paying a premium. The light is pleasant, the dimming is smooth, and the bulb is practical for everyday use. For shoppers hunting the best bulbs for pot lights on a tighter budget, it is an easy one to consider.

Best For

Best for larger homes, basements, and anyone replacing several recessed bulbs at once. It is also a good match if you want warm light without spending too much.

Pros and Cons

Pros:
  • Low power use helps cut energy costs
  • Good value in a 12-pack
  • Soft white light feels comfortable in living spaces
  • Smooth dimming for casual home use
Cons:
  • Not as refined as premium brands
  • CRI is fine, but not class-leading
  • May be a little dim for very bright task areas

Customer Reviews

Customer Review: “Great price for a 12-pack. I used them in the basement and they look clean and warm.”

Customer Review: “Dimming works well and the bulbs do not feel cheap. Good value if you need a lot of pot lights.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

4. SYLVANIA ECO BR30 LED Bulb, Dimmable Soft White 2700K, 4-Pack

SYLVANIA ECO BR30 LED Bulb, Dimmable Soft White 2700K, 4-Pack

SYLVANIA ECO BR30 LED Bulb is a classic, easy-to-use recessed light bulb for everyday spaces. It gives off a soft white glow that feels familiar, and it uses less power than older bulbs without making the room feel cold.

Key Features That Stand Out

  • ✓ 10W LED replacement for standard 65W incandescent bulbs
  • ✓ Soft white 2700K tone for cozy indoor lighting
  • ✓ Dimmable for more control over room brightness
  • ✓ Up to 7,700 hours of lifespan
  • ✓ Compact 4-pack for small projects or room-by-room upgrades

Why We Recommend It

This bulb is a good fit when you want a trusted name and a simple lighting result. It is not flashy, but it gets the job done well in most home settings. If you are building a shortlist of the best bulbs for pot lights, this one earns a place because it is steady and predictable.

Best For

Best for smaller homes, apartments, or anyone testing a new bulb before buying in bulk. It is also a good match for bedrooms and hallways.

Pros and Cons

Pros:
  • Comfortable warm light
  • Reliable brand reputation
  • Good for smaller replacement jobs
  • Energy saving compared with older bulbs
Cons:
  • Only a 4-pack, so less value for larger projects
  • Not adjustable in color temperature
  • May not be bright enough for work-heavy rooms

Customer Reviews

Customer Review: “Nice soft light and they dim without any trouble. Perfect for our hallway pot lights.”

Customer Review: “Simple bulb, no issues, and the color looks good in the bedroom.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

5. Feit Electric BR30 LED Flood Bulbs, Dimmable 5CCT Adjustable White, 6-Pack

Feit Electric BR30 LED Flood Bulbs, Dimmable 5CCT Adjustable White, 6-Pack

The Feit Electric BR30 LED Flood Bulbs stand out because of the adjustable white settings. That makes them handy if you are not sure whether you want warm, neutral, or daylight-style lighting in your pot lights.

Key Features That Stand Out

  • ✓ 5 color temperatures from 2700K to 5000K
  • ✓ Dimmable from 10% to 100%
  • ✓ 7.2W power draw with 65W-equivalent brightness
  • ✓ 650 lumens for a brighter recessed light feel
  • ✓ Good choice for rooms with changing lighting needs

Why We Recommend It

This is the bulb I would point to if you want flexibility. You can test different color tones and settle on what feels best in your home. It is especially useful in open layouts where one room flows into another.

Best For

Best for people who want to fine-tune the look of their recessed lights. It is also a smart pick for kitchens, offices, and multipurpose rooms.

Pros and Cons

Pros:
  • Adjustable color temperature is very useful
  • Bright output for pot lights
  • Energy efficient for daily use
  • Works well in different room types
Cons:
  • More complex than a basic bulb
  • May cost more than fixed-color options
  • Some users may prefer a simpler warm-white bulb

Customer Reviews

Customer Review: “I like being able to change the color temperature. It made it easy to match the kitchen and dining area.”

Customer Review: “Bright, efficient, and the dimming works nicely. Great for recessed lights in the main living space.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

6. DEGNJU BR30 LED Recessed Light Bulbs, 12-Pack Dimmable Soft White, E26 Base

DEGNJU BR30 LED Recessed Light Bulbs, 12-Pack Dimmable Soft White, E26 Base

DEGNJU BR30 LED Recessed Light Bulbs are built for people who want a soft, comfortable glow and low running costs. They are a practical pick for homes where pot lights stay on for long stretches.

Key Features That Stand Out

  • ✓ Smooth dimming from 10% to 100%
  • ✓ 2700K soft white light for a relaxed feel
  • ✓ 7W equivalent design helps save energy
  • ✓ High CRI 80+ for natural color appearance
  • ✓ 12-pack works well for whole-room upgrades

Why We Recommend It

This bulb is a good all-around choice if you want a warm room without a harsh look. It is easy to live with and easy to install. For anyone comparing the best bulbs for pot lights, this one is especially appealing when value and softness matter most.

Best For

Best for bedrooms, family rooms, and other places where you want a calm light. It also makes sense if you are replacing multiple bulbs at once.

Pros and Cons

Pros:
  • Comfortable warm light for daily use
  • Good energy savings
  • Large pack size adds value
  • Natural-looking color quality
Cons:
  • Not the brightest option on the list
  • Warm tone may not suit every room
  • Basic feature set compared with adjustable models

Customer Reviews

Customer Review: “These gave our family room a softer look right away. The dimming is smooth and the color is nice.”

Customer Review: “Great value in a 12-pack. I used them in recessed cans and they work as expected.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

7. Sigalux BR30 LED Flood Bulbs, 12-Pack Dimmable Soft White 2700K, E26 Base

Sigalux BR30 LED Flood Bulbs, 12-Pack Dimmable Soft White 2700K, E26 Base

The Sigalux BR30 LED Flood Bulbs are aimed at people who want soft white light with smooth dimming. They are a solid fit for recessed lighting in spaces where comfort matters more than super bright output.

Key Features That Stand Out

  • ✓ Flicker-free dimming from 10% to 100%
  • ✓ 2700K soft white tone for a warm home feel
  • ✓ 7.5W power use with 65W-equivalent brightness
  • ✓ CRI 80 for balanced color appearance
  • ✓ 12-pack gives you good coverage for larger spaces

Why We Recommend It

This bulb keeps things simple in a good way. It is efficient, comfortable, and works well in the rooms where you spend the most time. If you want the best bulbs for pot lights with a soft, familiar glow, this is a dependable option.

Best For

Best for bedrooms, living rooms, and hallways where a cozy tone is preferred. It is also a nice choice for replacing many bulbs at once.

Pros and Cons

Pros:
  • Soft white light is easy on the eyes
  • Good energy efficiency
  • Large pack works for bigger homes
  • Flicker-free dimming is a plus
Cons:
  • Not ideal if you want a crisp daylight tone
  • Color rendering is decent, not premium
  • May feel too gentle for task lighting

Customer Reviews

Customer Review: “Nice warm light and no flicker in our recessed cans. They feel comfortable in the evenings.”

Customer Review: “A very good value pack. The bulbs dim smoothly and look clean in the ceiling.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

8. Sigalux BR30 LED Flood Bulbs, 6-Pack Dimmable Soft White 2700K, E26 Base

Sigalux BR30 LED Flood Bulbs, 6-Pack Dimmable Soft White 2700K, E26 Base

Sigalux BR30 LED Flood Bulbs in the 6-pack are a smaller buy for people who do not need a big bulk box. They still give you the same warm, soft feel, which makes them useful for smaller rooms or a first test run.

Key Features That Stand Out

  • ✓ Smooth flicker-free dimming
  • ✓ 2700K soft white for cozy lighting
  • ✓ 7.5W energy use with strong efficiency
  • ✓ E26 base for standard recessed fixtures
  • ✓ Smaller 6-pack for moderate needs

Why We Recommend It

This version makes sense if you only need a few bulbs or want to try the brand first. The lighting quality is similar to the larger pack, so you are mostly choosing based on quantity. It is still a good candidate among the best bulbs for pot lights if your project is small.

Best For

Best for small homes, condos, and single-room updates. It is also useful if you only need to replace a handful of recessed bulbs.

Pros and Cons

Pros:
  • Good for smaller purchases
  • Soft light works in many rooms
  • Efficient and easy to install
  • Same core lighting feel as the 12-pack
Cons:
  • Less value than buying in bulk
  • Not a great fit for bright task spaces
  • No color temperature options

Customer Reviews

Customer Review: “Bought these for the den and they fit perfectly. The light is warm and pleasant.”

Customer Review: “Good little pack for a small project. Dimming is smooth and the bulbs look nice.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

9. DEGNJU BR30 LED Bulb, 6-Pack Dimmable Recessed Flood Lights, 2700K Soft White

DEGNJU BR30 LED Bulb, 6-Pack Dimmable Recessed Flood Lights, 2700K Soft White

The DEGNJU BR30 LED Bulb in the 6-pack gives you the same warm, soft feel as the larger set, but in a smaller bundle. It is a sensible buy if you want to update a few pot lights without overbuying.

Key Features That Stand Out

  • ✓ Smooth quiet dimming from 10% to 100%
  • ✓ 2700K soft white light
  • ✓ 7W equivalent with good energy savings
  • ✓ CRI 80+ for natural-looking color
  • ✓ Compact 6-pack for smaller projects

Why We Recommend It

This bulb feels like a practical middle ground. It is not overloaded with features, but it does the important things well. If you want the best bulbs for pot lights for a small space, this is a sensible and affordable choice.

Best For

Best for small room updates, spare bulbs, and homeowners who want a warm look without buying a huge box. It is also nice for hallways and bedrooms.

Pros and Cons

Pros:
  • Easy to use and install
  • Warm light fits most home settings
  • Good energy savings
  • Smaller pack is convenient
Cons:
  • Less value than larger multipacks
  • Only one color temperature
  • Not the strongest brightness option

Customer Reviews

Customer Review: “Worked well in my hallway recessed lights. The color is soft and comfortable.”

Customer Review: “A nice small pack for a quick upgrade. No issues with dimming so far.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

10. MASTERY MART BR30 LED Light Bulbs, 12-Pack Dimmable Daylight 5000K, E26 Base

MASTERY MART BR30 LED Light Bulbs, 12-Pack Dimmable Daylight 5000K, E26 Base

The MASTERY MART BR30 LED Light Bulbs are for people who want a brighter, cleaner-looking pot light. The 5000K daylight tone is more crisp than the warm options above, so it works better in active spaces.

Key Features That Stand Out

  • ✓ 5000K daylight color for a bright, clear look
  • ✓ 700 lumens for stronger room illumination
  • ✓ Flicker-free design helps reduce eye strain
  • ✓ E26 base fits common recessed cans
  • ✓ 12-pack is useful for larger lighting projects

Why We Recommend It

This bulb is a good pick if you like brighter, more modern light. It is especially useful in places where you need to see details well. If your search for the best bulbs for pot lights leans toward daylight brightness, this one is worth a look.

Best For

Best for kitchens, offices, laundry rooms, and work areas. It is also useful in spaces where you want a clean white look instead of a warm glow.

Pros and Cons

Pros:
  • Bright daylight output
  • Good for task-oriented rooms
  • Flicker-free design is helpful
  • Strong value in a 12-pack
Cons:
  • 5000K may feel too cool for bedrooms
  • Not the coziest choice for relaxation
  • Daylight tone can feel harsh in some homes

Customer Reviews

Customer Review: “Very bright and clean-looking. These work great in the kitchen and make everything easier to see.”

Customer Review: “Good daylight bulbs for recessed lights. I would not use them in a bedroom, but they are perfect for work areas.”

Complete Buying Guide for Best Bulbs For Pot Lights

Essential Factors We Consider

When choosing the best bulbs for pot lights, start with bulb shape, base type, and color temperature. BR30 bulbs are usually the best fit for recessed cans because they spread light well and do not look awkward in the ceiling. After that, think about dimming, brightness, and whether you want warm white for comfort or daylight for tasks.

If you are also planning outdoor upgrades, you may want to compare these with our guide to the best outdoor flood light bulbs or our roundup of outdoor spot lights for the house. For indoor recessed lighting, though, the goal is usually simple: soft light, low heat, and easy control.

Budget Planning

Buying pot light bulbs in multipacks can save money fast, especially if your home has a lot of recessed fixtures. If you only need a few bulbs, a smaller pack may make more sense, but bulk packs usually give better value per bulb. It is also smart to think about energy use over time, since LED bulbs can keep your electric bill lower for years.

Also, do not focus only on the sticker price. A bulb that dims smoothly and lasts longer can save you time and frustration later. That is why many homeowners choose a mid-range pack instead of the cheapest option on the shelf.

Final Thoughts

The right pot light bulb can change how a room feels more than people expect. Warm bulbs make a home feel calm, while daylight bulbs can make a space feel sharper and more useful. If you want more lighting ideas for around the house, you might also like our article on best outdoor lights for Cape Cod style house.

Frequently Asked Questions

Q: What type of bulb is best for pot lights?

A: BR30 LED bulbs are usually the best choice for pot lights because they fit recessed cans well and spread light evenly.

Q: What color temperature is best for pot lights in a living room?

A: A 2700K to 3000K bulb is usually best for living rooms because it gives a warm and relaxed feel.

Q: Can I use dimmable bulbs in all pot lights?

A: You can use dimmable bulbs only if your fixture and dimmer are compatible. If not, the bulb may flicker or not dim properly.

Q: Are daylight bulbs good for pot lights?

A: Yes, but mostly in kitchens, offices, and laundry rooms. They are brighter and cooler, so they are not always the best fit for cozy spaces.

Q: How many lumens do I need for recessed lighting?

A: For most home pot lights, 500 to 700 lumens works well. The right amount depends on room size and how bright you want it.

At the end of the day, the best bulbs for pot lights are the ones that match your room, your dimmer, and the mood you want. If you want warm comfort, flexible brightness, or a brighter daylight look, there is a good option in this list. Pick the one that fits your space best, and your recessed lighting will feel a lot better almost immediately.

If you are ready to upgrade your ceiling lights, start with the bulb that matches your room style and check today’s price before you buy.

// Fetch real-time product data for all products when page loads
(function() {
const products = [‘B01MTENTQ0’, ‘B07JMBTQ57’, ‘B0CSK96CS7’, ‘B08HSC7P7H’, ‘B0DPR9QF13’, ‘B0D6QNMJ95’, ‘B0GGB7QKZD’, ‘B0GGBC75HC’, ‘B0D6QMSKJR’, ‘B0DP9H7GG8’];
const affiliateTag = ‘accurategoods02-20’;

async function fetchLiveProductData(asin) {
try {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘⏳ Fetching…’;

const amazonUrl = ‘https://www.amazon.com/dp/’ + asin;
const response = await fetch(‘https://api.allorigins.win/raw?url=’ + encodeURIComponent(amazonUrl));
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, ‘text/html’);

let price = null;
const priceWhole = doc.querySelector(‘.a-price-whole’);
const priceFraction = doc.querySelector(‘.a-price-fraction’);
if (priceWhole) {
price = ‘$’ + priceWhole.textContent.trim() + (priceFraction ? priceFraction.textContent.trim() : ”);
}

let rating = null;
const ratingEl = doc.querySelector(‘[data-hook=”average-star-rating”] .a-icon-alt’);
if (ratingEl) {
const match = ratingEl.textContent.match(/(\d+\.\d+)/);
if (match) rating = match[1];
}

let reviewCount = null;
const reviewEl = doc.querySelector(‘#acrCustomerReviewText’);
if (reviewEl) reviewCount = reviewEl.textContent.trim();

if (price) {
const priceEl = document.getElementById(‘price-‘ + asin);
if (priceEl) {
priceEl.innerHTML = price;
priceEl.style.animation = ‘pulse 0.5s’;
}
}

// if (rating) {
// const ratingEl = document.getElementById(‘rating-‘ + asin);
// if (ratingEl) {
// const stars = ‘⭐’.repeat(Math.floor(parseFloat(rating)));
// ratingEl.innerHTML = stars + ‘ ‘ + rating + ‘/5’;
// ratingEl.style.animation = ‘pulse 0.5s’;
// }
// }

if (reviewCount) {
const reviewsEl = document.getElementById(‘reviews-‘ + asin);
if (reviewsEl) {
reviewsEl.innerHTML = reviewCount;
reviewsEl.style.animation = ‘pulse 0.5s’;
}
}

if (updateTimeEl) {
const now = new Date();
const timeStr = now.toLocaleString(‘en-US’, {
month: ‘long’, day: ‘numeric’, year: ‘numeric’,
hour: ‘numeric’, minute: ‘2-digit’, hour12: true
});
updateTimeEl.innerHTML = ‘✓ Updated: ‘ + timeStr;
}
} catch (error) {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘✓ Cached data’;
}
}

const style = document.createElement(‘style’);
style.textContent = `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }`;
document.head.appendChild(style);

function loadAllProducts() {
products.forEach((asin, index) => {
setTimeout(() => fetchLiveProductData(asin), index * 2000);
});
}

if (document.readyState === ‘loading’) {
document.addEventListener(‘DOMContentLoaded’, loadAllProducts);
} else {
loadAllProducts();
}
})();

Leave a Comment