diff --git a/refill.js b/refill.js index 7b9a6d1..b345c8e 100644 --- a/refill.js +++ b/refill.js @@ -37,6 +37,15 @@ const SITE = 'https://instantadpay.com'; const n0 = v => (typeof v === 'number' && isFinite(v) ? v : 0); const money = n => Number(n || 0).toLocaleString('en-US'); const delivered = c => n0(c.spent) + n0(c.accrued); +// video campaigns count watches, not impressions, and the relaunch maths only makes sense with the per-watch price (Marty, 2026-09-30) +const unit = c => c.type === 'video' ? 'watches' : 'impressions'; +function videoNote(c) { + if (c.type !== 'video') return ''; + const secs = Number(c.body) || 0; let cost = 0; + try { cost = ((X.ads.rates().videoTiers || []).find(t => t.secs === secs) || {}).cost || 0; } catch (e) {} + if (!secs || !cost) return ''; + return ' (' + secs + '-second video at ' + cost + ' credits a watch: every ' + money(cost * 100) + ' credits buys about 100 more watches)'; +} const key = (id, state) => id + ':' + state; // the five packages and what each dollar buys, so the ladder is never hand-typed @@ -69,9 +78,9 @@ function ladderHtml() { function describe(list) { return list.map(c => { const bits = [money(Math.round(delivered(c))) + ' of ' + money(Math.round(n0(c.budget))) + ' credits delivered']; - if (n0(c.imps)) bits.push(money(n0(c.imps)) + ' impressions'); + if (n0(c.imps)) bits.push(money(n0(c.imps)) + ' ' + unit(c)); if (n0(c.clicks)) bits.push(money(n0(c.clicks)) + ' clicks'); - return ' "' + (c.name || c.title || ('campaign #' + c.id)) + '" (' + (c.type || 'ad') + '): ' + bits.join(', '); + return ' "' + (c.name || c.title || ('campaign #' + c.id)) + '" (' + (c.type || 'ad') + '): ' + bits.join(', ') + videoNote(c); }).join('\n'); } @@ -101,7 +110,7 @@ async function compose(owner, list, state, credits) { + '

' + next.replace(/(https:\/\/[^\s]+)/g, '$1') + '

' + '

What each one did:

' + + (n0(c.imps) ? ', ' + money(n0(c.imps)) + ' ' + unit(c) : '') + (n0(c.clicks) ? ', ' + money(n0(c.clicks)) + ' clicks' : '') + esc(videoNote(c)) + '').join('') + '' + ladderHtml() + '

Every package pays your sponsor line in the same on-chain transaction, and every payout is on the public ledger.

'; return { subject, text, html };