Using affiliate parameters for Bang, fixed affiliate URL composition on entity page.

This commit is contained in:
DebaucheryLibrarian 2023-06-19 05:19:49 +02:00
parent 54c501e277
commit b5309005e9
2 changed files with 11 additions and 3 deletions

View File

@ -157,12 +157,14 @@ async function fetchEntity(scroll = true) {
const campaign = entity.campaigns.find((campaignX) => !campaignX.banner) const campaign = entity.campaigns.find((campaignX) => !campaignX.banner)
|| entity.parent?.campaigns.find((campaignX) => !campaignX.banner); || entity.parent?.campaigns.find((campaignX) => !campaignX.banner);
const { searchParams, pathname, origin } = new URL(entity.url);
const affiliateParams = new URLSearchParams({ const affiliateParams = new URLSearchParams({
...(entity.url && Object.fromEntries(new URL(entity.url).searchParams)), // preserve any query in entity URL, e.g. ?siteId=5 ...(entity.url && Object.fromEntries(searchParams)), // preserve any query in entity URL, e.g. ?siteId=5
...(campaign?.affiliate?.parameters && Object.fromEntries(new URLSearchParams(campaign.affiliate.parameters))), // append affiliate parameters ...(campaign?.affiliate?.parameters && Object.fromEntries(new URLSearchParams(campaign.affiliate.parameters))), // append affiliate parameters
}).toString(); }).toString();
this.entityUrl = campaign?.url || campaign?.affiliate?.url || `${entity.url}${campaign?.affiliate?.parameters ? `?${affiliateParams}` : ''}`; this.entityUrl = campaign?.url || campaign?.affiliate?.url || `${origin}${pathname}${campaign?.affiliate?.parameters ? `?${affiliateParams}` : ''}`;
this.done = true; this.done = true;
if (scroll && this.$refs.filter?.$el) { if (scroll && this.$refs.filter?.$el) {

View File

@ -15,6 +15,12 @@ const affiliates = [
parameters: 't=eyJhZmZpbGlhdGUiOiJEZWJhdWNoZXJ5TGliIiwiY2FtcGFpZ24iOiJkZWZhdWx0IiwiYWdldmVyaWZpZWQiOiJ5In0', parameters: 't=eyJhZmZpbGlhdGUiOiJEZWJhdWNoZXJ5TGliIiwiY2FtcGFpZ24iOiJkZWZhdWx0IiwiYWdldmVyaWZpZWQiOiJ5In0',
comment: '50%', comment: '50%',
}, },
{
id: 'bang_signup',
network: 'bang',
parameters: 't=eyJhZmZpbGlhdGUiOiJEZWJhdWNoZXJ5TGliIiwiY2FtcGFpZ24iOiJkZWZhdWx0IiwiYWdldmVyaWZpZWQiOiJ5In0',
comment: '$25 per signup',
},
]; ];
const bannerTags = { const bannerTags = {
@ -241,7 +247,7 @@ const campaigns = [
// bang // bang
{ {
network: 'bang', network: 'bang',
url: 'https://www.bang.com/?aff=eyJ3IjoiMTQ1ODYiLCJsIjoiMzE2NDYiLCJ0IjoiNDU4NjEifQ==', affiliate: 'bang_signup',
comment: 'per signup', comment: 'per signup',
}, },
// julesjordan // julesjordan