Release v0.1.1: hide sponsored listings, broaden detail-page detection
- Hide any card whose anchor carries `journey=FEATURED_LISTING_JOURNEY`
or whose container is tagged featured/sponsor/promoted.
- Detail-page URL regex now also matches `/classifieds/advert/{id}` and
`/cars/{slug}/{id}` in case AutoTrader redirects through either.
- Added a `[ATM]` console.log at init so unresolved detection issues can
be diagnosed from Firefox DevTools.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,6 +61,11 @@ html.atm-hide-dismissed .atm-card.atm-dismissed {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Sponsored / featured listings — fully hidden */
|
||||
.atm-sponsored {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* --- Detail page: floating action button --- */
|
||||
|
||||
.atm-fab {
|
||||
|
||||
+48
-2
@@ -69,11 +69,39 @@ function extractTitle(card) {
|
||||
return h ? h.textContent.trim().slice(0, 200) : "";
|
||||
}
|
||||
|
||||
// A card is "sponsored/featured" if its detail link carries
|
||||
// journey=FEATURED_LISTING_JOURNEY (AutoTrader's own tagging) or it lives
|
||||
// inside an explicitly sponsored container.
|
||||
function isSponsoredCard(card) {
|
||||
const anchors = card.querySelectorAll('a[href*="/car-details/"]');
|
||||
for (const a of anchors) {
|
||||
const href = a.getAttribute("href") || "";
|
||||
if (/journey=FEATURED_LISTING_JOURNEY/i.test(href)) return true;
|
||||
}
|
||||
const testid = (card.getAttribute("data-testid") || "").toLowerCase();
|
||||
if (testid.includes("featured") || testid.includes("sponsor") || testid.includes("promoted")) {
|
||||
return true;
|
||||
}
|
||||
// Walk up one level to catch wrapper markers
|
||||
const parent = card.parentElement;
|
||||
if (parent) {
|
||||
const ptid = (parent.getAttribute("data-testid") || "").toLowerCase();
|
||||
if (ptid.includes("featured") || ptid.includes("sponsor") || ptid.includes("promoted")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function findAllCards() {
|
||||
// Primary selector — verified stable on autotrader.co.uk
|
||||
const lis = document.querySelectorAll('li[data-testid^="id-"]');
|
||||
const cards = new Map();
|
||||
for (const li of lis) {
|
||||
if (isSponsoredCard(li)) {
|
||||
li.classList.add("atm-sponsored");
|
||||
continue;
|
||||
}
|
||||
const id = extractIdFromLi(li);
|
||||
if (id) cards.set(li, id);
|
||||
}
|
||||
@@ -153,8 +181,17 @@ function startObserving() {
|
||||
// doesn't depend on the page layout, so it's resilient to redesigns.
|
||||
|
||||
function getDetailListingId() {
|
||||
const m = location.pathname.match(/^\/car-details\/(\d+)/);
|
||||
return m ? m[1] : null;
|
||||
// Accept /car-details/{id}, /classifieds/advert/{id}, trailing slashes, slugs
|
||||
const patterns = [
|
||||
/^\/car-details\/(\d+)/i,
|
||||
/^\/classifieds\/advert\/(\d+)/i,
|
||||
/\/cars?\/[^/]+\/(\d{10,})/i,
|
||||
];
|
||||
for (const re of patterns) {
|
||||
const m = location.pathname.match(re);
|
||||
if (m) return m[1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function extractDetailTitle() {
|
||||
@@ -282,6 +319,15 @@ function watchUrlChanges() {
|
||||
|
||||
(async function init() {
|
||||
await loadState();
|
||||
const detailId = getDetailListingId();
|
||||
// Diagnostic log — open Firefox DevTools console to confirm detection.
|
||||
// Prefixed so you can filter with "ATM" in the console.
|
||||
console.log("[ATM]", {
|
||||
pathname: location.pathname,
|
||||
href: location.href,
|
||||
detectedDetailId: detailId,
|
||||
dismissedCount: Object.keys(state.dismissed).length,
|
||||
});
|
||||
applyPageMode();
|
||||
watchUrlChanges();
|
||||
})();
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
+4
@@ -5,6 +5,10 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"update_link": "https://git.nocker.cloud/tony/autotrader-marker/raw/branch/main/dist/autotrader-marker-0.1.0.xpi"
|
||||
},
|
||||
{
|
||||
"version": "0.1.1",
|
||||
"update_link": "https://git.nocker.cloud/tony/autotrader-marker/raw/branch/main/dist/autotrader-marker-0.1.1.xpi"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "AutoTrader Marker",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"description": "Mark AutoTrader listings as 'not wanted' so you can spot the ones you haven't reviewed yet.",
|
||||
"permissions": [
|
||||
"storage"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "autotrader-marker",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"private": true,
|
||||
"description": "Firefox extension that marks AutoTrader listings as 'not wanted'.",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user