AI ad writer on the text-ad form (Marty 2026-11-17: "do it on the other sites too"): "Write my ad from my link" asks the network hub (hubadwriter.js, POST /v1/adwriter, 60/90 limits) for 3 ads from the member's own page; shown only when the hub says on; chatbot fact; my.js?v=9

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 08:00:39 -06:00
parent b062939577
commit e0adc62c31
7 changed files with 133 additions and 3 deletions
+17
View File
@@ -44,6 +44,23 @@
const isSpin = v => { v = String(v || '').trim().toLowerCase(); if (spinAd && v === String(spinAd).toLowerCase()) return true; return !!(spins && spins.some(x => x.url.toLowerCase() === v)); };
const spinMark = () => { const on = isSpin($('fLink').value); $('fTrack').disabled = on; $('trackNote').hidden = !on; $('fTrack').closest('label').style.opacity = on ? '0.6' : ''; };
$('fLink').addEventListener('input', spinMark);
// the AI ad writer (Marty 2026-11-17): 3 suggestions the hub writes only from the member's own page; picking one fills the form
if (c.aiWriter) {
$('aiBox').hidden = false;
let opts = [];
$('aiWrite').onclick = async () => {
const box = $('aiList'), url = $('fLink').value.trim(); box.hidden = false;
if (!/^https?:\/\/\S+\.\S+/i.test(url)) { box.innerHTML = '<p class="small" style="margin:0">Put your link in the Your link box first (starting with https://), then tap the button again.</p>'; $('fLink').focus(); return; }
$('aiWrite').disabled = true; box.innerHTML = '<p class="small muted" style="margin:0">Reading your page and writing 3 ads. This takes a few seconds...</p>';
const r = await VAB.post('/api/my/adwriter', { url }).catch(() => ({ error: 'The ad writer did not answer. Try again in a minute.' }));
$('aiWrite').disabled = false;
if (r.error) { box.innerHTML = '<p class="small" style="margin:0">' + esc(r.error) + '</p>'; return; }
opts = r.options || [];
box.innerHTML = '<p class="small muted" style="margin:0 0 8px">Tap one to use it. Check every word is true for your offer before you post.' + (typeof r.left === 'number' ? ' Ad writes left today: ' + r.left + '.' : '') + '</p>'
+ opts.map((o, i) => '<button type="button" class="btn-soft" data-ai="' + i + '" style="display:block;width:100%;text-align:left;margin:0 0 6px"><b>' + esc(o.headline) + '</b><br><span class="small">' + esc(o.line || '') + '</span></button>').join('');
box.querySelectorAll('button[data-ai]').forEach(b => { b.onclick = () => { const o = opts[Number(b.dataset.ai)]; $('fHead').value = o.headline; $('fL1').value = o.line || ''; ['fHead', 'fL1'].forEach(id => $(id).dispatchEvent(new Event('input'))); box.hidden = true; VAB.status('Filled in. Edit it as you like, then save your ad.', 'ok'); }; });
};
}
$('spinBtn').onclick = async () => {
const box = $('spinList');
if (!box.hidden) { box.hidden = true; return; }