>>17062737(function(){
console.log('loaded');
async function load(){
const m=await import('
https://esm.sh/nostr-tools@2.17.0/pure');
window.n=m;
const ns="wholesome-chungus-party-v1-";
const cb=window.currentBoard||{tag:ns+"soy"};
window.make=function(s,c,i,r){
const t=[["t",cb.tag]];
if(s)t.push(["subject",s]);
if(i)t.push(["image",i]);
if(r&&/^[0-9a-f]{64}$/i.test(r))t.push(["e",r,"","reply"]);
let h=localStorage.getItem('wcp-v1-secret-key-hex');
if(!h||!/^[0-9a-f]{64}$/i.test(h)){
const b=m.generateSecretKey();
h=Array.from(b,x=>x.toString(16).padStart(2,'0')).join('');
localStorage.setItem('wcp-v1-secret-key-hex',h);
}
const k=new Uint8Array(h.match(/.{2}/g).map(x=>parseInt(x,16)));
return m.finalizeEvent({kind:1,created_at:Math.floor(Date.now()/1000),tags:t,content:c},k);
};
window.send=function(e,relays){
const r=relays||["wss://relay.damus.io","wss://nos.lol","wss://relay.nostr.band","wss://relay.primal.net"];
return Promise.allSettled(r.map(url=>new Promise(resolve=>{
let settled=false;
const finish=(v)=>{if(!settled){settled=true;resolve(v);}};
let ws;
try{ws=new WebSocket(url);}catch(err){finish({ok:false,error:err});return;}
const timer=setTimeout(()=>{try{ws.close();}catch{}finish({ok:false,error:'timeout'});},5000);
ws.addEventListener('open',()=>{
try{ws.send(JSON.stringify(['EVENT',e]));}
catch(err){clearTimeout(timer);try{ws.close();}catch{}finish({ok:false,error:err});}
});
ws.addEventListener('message',ev=>{
let msg;
try{msg=JSON.parse(ev.data);}catch{return;}
if(Array.isArray(msg)&&msg[0]
='OK'&&msg[1]=e.id){
clearTimeout(timer);
try{ws.close();}catch{}
finish({ok:msg[2]===true,message:msg[3]||''});
}
});
ws.addEventListener('error',()=>{clearTimeout(timer);try{ws.close();}catch{}finish({ok:false,error:'error'});});
ws.addEventListener('close',()=>{if(!settled){clearTimeout(timer);finish({ok:false,error:'closed'});}});
})));
};
window.posts=window.posts||new Map();
window.render=window.render||function(){};
console.log('ready');
}
window.verifyCaptcha=function(){return true;};
window.drawCaptcha=function(){};
window.captchaAnswer='AAAAA';
window.checkAntiSpam=function(){return {ok:true};};
window.loadSpamHistory=function(){return[];};
window.loadJsonArray=function(){return[];};
window.recordSuccessfulSpamPost=function(){};
window.saveSpamHistory=function(){};
window.saveJsonArray=function(){};
window.textLooksSpammy=function(){return false;};
window.validImageUrl=function(){return true;};
window.imageUrlError=function(){return '';};
setInterval(function(){
const x=document.getElementById('wcp-local-captcha-input');
if(x)x.value='AAAAA';
},100);
let posting=false;
let queue=[];
let total=0;
let interval=null;
let count=0;
async function post(msg){
if(posting){queue.push(msg);return;}
posting=true;
try{
const ev=window.make(msg,msg,
,);
const res=await window.send(ev);
const ok=res.filter(r=>r.status==='fulfilled'&&r.value&&r.value.ok).length;
if(ok>=1){
if(window.posts)window.posts.set(ev.id,ev);
if(window.render)window.render();
total++;
console.log('['+total+'] ok '+msg);
return true;
}else{
console.log('['+total+'] fail '+msg);
return false;
}
}catch(e){
console.log('err '+msg);
return false;
}finally{
posting=false;
if(queue.length>0){
const n=queue.shift();
setTimeout(()=>post(n),1500);
}
}
}
window.start=function(ms){
if(interval)clearInterval(interval);
count=0;total=0;queue=[];
console.log('starting');
function go(){count++;post('kansas vvqn #'+count);}
go();
interval=setInterval(go,ms||3000);
};
window.stop=function(){
if(interval){clearInterval(interval);interval=null;console.log('stopped '+total);}
};
load();
console.log('type start(3000)');
})();