From 6aaa3ad30c21e557b3224ed3fefe8497bcd57420 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Fri, 6 Feb 2026 23:55:06 +0100 Subject: [PATCH] Allowing campaigns to be marked as non-global. --- src/campaigns.js | 9 +++++++++ static | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/campaigns.js b/src/campaigns.js index ab6e3b2..17a9397 100644 --- a/src/campaigns.js +++ b/src/campaigns.js @@ -82,18 +82,27 @@ export async function getRandomCampaign(options = {}, context = {}, pass = 0) { const validCampaigns = campaigns.filter((campaign) => { if (options.minRatio && (!campaign.banner || campaign.banner.ratio < options.minRatio)) { + // too small return false; } if (options.maxRatio && (!campaign.banner || campaign.banner.ratio > options.maxRatio)) { + // too big return false; } if (options.entityIds && !options.entityIds.some((entityId) => campaign.entity.id === entityId || campaign.entity.parent?.id === entityId)) { + // this is an entity page, this campaign does not belong to this entity + return false; + } + + if (campaign.affiliate?.parameters?.global === false && !options.entityIds) { + // this campaign should only show on entity page return false; } if (context.tagFilter && campaign.banner && campaign.banner.tags.some((tag) => context.tagFilter.includes(tag) && !options.tagSlugs?.includes(tag))) { + // wrong tag return false; } diff --git a/static b/static index 4e5c91d..13a0a44 160000 --- a/static +++ b/static @@ -1 +1 @@ -Subproject commit 4e5c91df28209e9f2327d6d4fbe04a79472b166f +Subproject commit 13a0a44985449987afad3b61d5e43cb487d77cfd