Skip to content

Instantly share code, notes, and snippets.

@munierujp
Last active September 26, 2025 08:19
Show Gist options
  • Select an option

  • Save munierujp/39955d9d58230bd0a465a2b3df61c893 to your computer and use it in GitHub Desktop.

Select an option

Save munierujp/39955d9d58230bd0a465a2b3df61c893 to your computer and use it in GitHub Desktop.
This script highlights differences on the device comparison page on Apple's website. Paste it into the developer tools console and run it. This script was generated by ChatGPT.
(() => {
// --- Custom Styles ---
const STYLE_ID = 'compare-diff-style-2';
if (!document.getElementById(STYLE_ID)) {
const style = document.createElement('style');
style.id = STYLE_ID;
style.textContent = `
.diff-yellow {
background: rgba(255, 255, 150, 0.8) !important;
}
.diff-green {
background: rgba(100, 255, 100, 0.8) !important;
}
`;
document.head.appendChild(style);
}
const rows = document.querySelectorAll('.compare-row');
rows.forEach(row => {
const cells = Array.from(row.querySelectorAll('div[role^="cell"], .compare-column'))
.filter(el => el.closest('.compare-row') === row);
if (cells.length < 3) return; // Only apply when there are 3 or more columns
// Normalize text
const values = cells.map(c => (c.innerText || '').replace(/\s+/g, ' ').trim());
// Clear existing highlights
cells.forEach(c => c.classList.remove('diff-yellow', 'diff-green'));
// Check for differences in the 2nd cell
if (values[1] !== values[0]) {
cells[1].classList.add('diff-yellow');
}
// Check for differences in the 3rd cell
if (values[2] !== values[0]) {
if (values[2] === values[1]) {
cells[2].classList.add('diff-yellow');
} else {
cells[2].classList.add('diff-green');
}
}
});
console.log('Conditional highlighting applied.');
})();
@munierujp
Copy link
Author

munierujp commented Sep 26, 2025

www apple com_iphone_compare__modelList=iphone-17,iphone-17-pro,iphone-17-pro-max(1080p)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment