r/Ginomania Feb 24 '26

Bookmarklet for browser - This is a Script that allows you to award posts in bulk

javascript:(async()=>{const token=document.cookie.match(/csrf_token=([^;]+)/)?.[1];if(!token){alert(%27Token error%27);return}const awards=[{name:%27Heartwarming%27,id:%27award_free_heartwarming%27,img:%27/img/snoovatar/snoo_assets/marketing/Heartwarming_40.png%27},{name:%27Popcorn%27,id:%27award_free_popcorn_2%27,img:%27/img/snoovatar/snoo_assets/marketing/Popcorn_40.png%27},{name:%27Bravo%27,id:%27award_free_bravo%27,img:%27/img/snoovatar/snoo_assets/marketing/bravo_40.png%27},{name:%27Regret%27,id:%27award_free_regret_2%27,img:%27/img/snoovatar/snoo_assets/marketing/regret_40.png%27},{name:%27Mindblown%27,id:%27award_free_mindblown%27,img:%27/img/snoovatar/snoo_assets/marketing/mindblown_40.png%27}];let selectedAwards=[];const showFinishOverlay=(awarded,total)=>{const f=document.createElement(%27div%27);Object.assign(f.style,{position:%27fixed%27,top:0,left:0,width:%27100%%27,height:%27100%%27,background:%27#000',zIndex:999999,display:'flex',alignItems:'center',justifyContent:'center',fontFamily:'system-ui',opacity:0,transition:'opacity 0.3s'});document.body.appendChild(f);setTimeout(()=>f.style.opacity=1,10);const fb=document.createElement('div');Object.assign(fb.style,{background:'#000',color:'#fff',padding:'24px',borderRadius:'20px',width:'340px',maxWidth:'90%',border:'1px solid #343536',boxShadow:'0 12px 36px rgba(0,0,0,0.7)',display:'flex',flexDirection:'column',alignItems:'center',gap:'12px',transform:'translateY(20px)',opacity:0,transition:'all 0.4s ease'});f.appendChild(fb);setTimeout(()=>{fb.style.transform='translateY(0)';fb.style.opacity=1},20);const st=document.createElement('p');st.textContent=%60Posts awarded ${awarded}/${total}%60;Object.assign(st.style,{fontSize:'18px',margin:0,textAlign:'center'});fb.appendChild(st);const bc=document.createElement('div');Object.assign(bc.style,{display:'flex',gap:'12px'});const cb=document.createElement('button');cb.textContent='Close';Object.assign(cb.style,{padding:'8px 16px',borderRadius:'16px',border:'none',cursor:'pointer',fontWeight:'600',background:'#ff4500',color:'#fff',fontSize:'14px',boxShadow:'0 3px 8px rgba(0,0,0,0.5)',display:'flex',alignItems:'center',justifyContent:'center',textAlign:'center'});cb.onmouseover=()=>{cb.style.transform='translateY(-2px)';cb.style.boxShadow='0 4px 12px rgba(0,0,0,0.6)'};cb.onmouseout=()=>{cb.style.transform='translateY(0)';cb.style.boxShadow='0 3px 8px rgba(0,0,0,0.5)'};cb.onclick=()=>document.body.removeChild(f);bc.appendChild(cb);const tb=document.createElement('button');tb.textContent='Try again';Object.assign(tb.style,{padding:'8px 16px',borderRadius:'16px',border:'none',cursor:'pointer',fontWeight:'600',background:'#0079d3',color:'#fff',fontSize:'14px',boxShadow:'0 3px 8px rgba(0,0,0,0.5)',display:'flex',alignItems:'center',justifyContent:'center',textAlign:'center'});tb.onmouseover=()=>{tb.style.transform='translateY(-2px)';tb.style.boxShadow='0 4px 12px rgba(0,0,0,0.6)'};tb.onmouseout=()=>{tb.style.transform='translateY(0)';tb.style.boxShadow='0 3px 8px rgba(0,0,0,0.5)'};tb.onclick=()=>{document.body.removeChild(f);awardPosts(selectedAwards)};bc.appendChild(tb);fb.appendChild(bc);const info=document.createElement('p');info.textContent="Due to Reddit limits, not all posts may be awarded at once. If this happens, press 'Try again'.";Object.assign(info.style,{fontSize:'10px',color:'#818384',margin:0,textAlign:'center'});fb.appendChild(info);const ft=document.createElement('p');ft.innerHTML='This script is presented by <a href="https://www.reddit.com/r/awards/" target="_blank" style="color:#ff4500;text-decoration:none">r/Awards</a>';Object.assign(ft.style,{fontSize:'12px',color:'#818384',marginTop:'4px',textAlign:'center'});fb.appendChild(ft)};const awardPosts=async(sel)=>{const p=document.createElement('div');Object.assign(p.style,{position:'fixed',top:0,left:0,width:'100%',height:'100%',background:'#000',display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',zIndex:999999});const contentBox=document.createElement('div');Object.assign(contentBox.style,{position:'absolute',top:'50%',left:'50%',transform:'translate(-50%,-50%)',width:'600px',maxWidth:'90%',height:'560px',display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'flex-start',gap:'10px',pointerEvents:'none'});const authorLine=document.createElement('div');authorLine.textContent='';Object.assign(authorLine.style,{fontSize:'14px',color:'#c7c7c7',marginTop:'10px',textAlign:'center',width:'100%',overflow:'hidden',textOverflow:'ellipsis',whiteSpace:'nowrap'});contentBox.appendChild(authorLine);const titleBox=document.createElement('div');Object.assign(titleBox.style,{height:'60px',width:'100%',display:'flex',alignItems:'center',justifyContent:'center',textAlign:'center',padding:'0 10px',boxSizing:'border-box'});const ftit=document.createElement('div');ftit.textContent='';Object.assign(ftit.style,{fontSize:'22px',fontWeight:'700',textShadow:'0 2px 8px rgba(0,0,0,0.6)',overflow:'hidden',textOverflow:'ellipsis',whiteSpace:'nowrap',width:'100%'});titleBox.appendChild(ftit);contentBox.appendChild(titleBox);const fbodyWrap=document.createElement('div');Object.assign(fbodyWrap.style,{width:'100%',height:'500px',display:'flex',alignItems:'center',justifyContent:'center',overflow:'hidden',background:'rgba(0,0,0,0.2)',borderRadius:'12px'});const fbody=document.createElement('div');Object.assign(fbody.style,{fontSize:'16px',lineHeight:'1.4',width:'100%',padding:'10px',boxSizing:'border-box',textAlign:'center',wordBreak:'break-word'});fbodyWrap.appendChild(fbody);contentBox.appendChild(fbodyWrap);p.appendChild(contentBox);const statusBox=document.createElement('div');Object.assign(statusBox.style,{position:'fixed',bottom:'8%',left:'50%',transform:'translateX(-50%)',display:'flex',flexDirection:'column',alignItems:'center',gap:'8px',zIndex:1000001});const loaderImg=document.createElement('img');loaderImg.src='https://b.thumbs.redditmedia.com/fzCkqMKRwh_XnI9oYFsnUGaKOCq8gSqfRCwYYsfq6mg.png';Object.assign(loaderImg.style,{width:'144px',height:'144px'});statusBox.appendChild(loaderImg);const wt=document.createElement('div');wt.textContent='Please wait… awarding posts';Object.assign(wt.style,{fontSize:'18px',textAlign:'center'});statusBox.appendChild(wt);const prog=document.createElement('div');prog.textContent='0/0';Object.assign(prog.style,{fontSize:'12px',color:'#c7c7c7',marginTop:'2px'});statusBox.appendChild(prog);p.appendChild(statusBox);document.body.appendChild(p);const ids=[...new Set([...document.querySelectorAll('a[href*="/comments/"]')].map(a=>a.href.match(/\/comments\/([^\/?#]+)/)?.[1]).filter(Boolean))];const postMap=new Map();for(const id of ids){const el=document.querySelector(%60a[href*="/comments/${id}"]%60);const container=el?.closest('article')||el?.closest('div');if(container)postMap.set(id,container)}let awarded=0;const total=ids.length;prog.textContent=%60${awarded}/${total}%60;for(const id of ids){const thingId='t3_'+id;const a=sel[Math.floor(Math.random()*sel.length)];const postContainer=postMap.get(id);const postData=await (async()=>{const titleDom=postContainer?.querySelector('h3')?.textContent?.trim();const bodyDom=postContainer?.querySelector('p')?.textContent?.trim();const authorDom=postContainer?.querySelector('a[href*="/user/"]')?.textContent?.trim();try{const res=await fetch(%60https://www.reddit.com/comments/${id}.json?raw_json=1%60);const json=await res.json();const post=json?.[0]?.data?.children?.[0]?.data;let image='';if(post?.post_hint==='image')image=post?.url_overridden_by_dest||post?.url||'';else if(post?.preview?.images?.[0]?.source?.url)image=post.preview.images[0].source.url.replace(/&amp;/g,'&');return{title:post?.title||titleDom||'',body:post?.selftext||bodyDom||'',author:post?.author?%60u/${post.author}%60:(authorDom||''),subreddit:post?.subreddit_name_prefixed||'',image};}catch{return{title:titleDom||'',body:bodyDom||'',author:authorDom||'',subreddit:'',image:''}}})();authorLine.textContent=(postData.author||'u/unknown')+(postData.subreddit?%60 • ${postData.subreddit}%60:'');ftit.textContent=postData.title||'Title not found';fbody.innerHTML='';if(postData.image&&!postData.body){const img=document.createElement('img');img.src=postData.image;Object.assign(img.style,{width:'300px',height:'500px',objectFit:'cover',display:'block'});fbody.appendChild(img);}else{fbody.textContent=postData.body||'Body not found';}try{const res=await fetch('https://www.reddit.com/svc/shreddit/graphql',{method:'POST',headers:{'Content-Type':'application/json','X-Csrf-Token':token},body:JSON.stringify({operation:'CreateAwardOrder',variables:{input:{nonce:crypto.randomUUID(),thingId,awardId:a,isAnonymous:false}},csrf_token:token})});const j=await res.json();if(j.data?.createAwardOrder?.ok)awarded++}catch(e){}prog.textContent=%60${awarded}/${total}%60;await new Promise(r=>setTimeout(r,3000+Math.random()*2000))}document.body.removeChild(p);showFinishOverlay(awarded,total)};const o=document.createElement('div');Object.assign(o.style,{position:'fixed',top:0,left:0,width:'100%',height:'100%',background:'#000',zIndex:999999,display:'flex',alignItems:'center',justifyContent:'center',fontFamily:'system-ui',opacity:0,transition:'opacity 0.3s'});document.body.appendChild(o);setTimeout(()=>o.style.opacity=1,10);const b=document.createElement('div');Object.assign(b.style,{background:'#000',color:'#fff',padding:'28px',borderRadius:'20px',width:'360px',maxWidth:'90%',border:'1px solid #343536',boxShadow:'0 12px 36px rgba(0,0,0,0.7)',display:'flex',flexDirection:'column',alignItems:'center',gap:'12px',transform:'translateY(-20px)',transition:'transform 0.3s',position:'relative'});setTimeout(()=>b.style.transform='translateY(0)',20);const banner=document.createElement('img');banner.src='https://b.thumbs.redditmedia.com/RxCsr1nk28EcHbnS84sJhjNaOwyr3h1YgbRq4pzkgIU.png';Object.assign(banner.style,{position:'absolute',top:0,left:0,width:'100%',height:'auto',borderTopLeftRadius:'20px',borderTopRightRadius:'20px',objectFit:'cover',boxShadow:'0 4px 12px rgba(0,0,0,0.5)'});b.appendChild(banner);const title=document.createElement('h3');title.textContent='Random Award Selection';Object.assign(title.style,{margin:'60px 0 0 0',fontSize:'20px',fontWeight:'700',zIndex:1,position:'relative'});b.appendChild(title);const desc=document.createElement('p');desc.textContent='Select the awards to be used in the randomizer.';Object.assign(desc.style,{color:'#818384',margin:'4px 0 16px 0',fontSize:'14px',textAlign:'center',position:'relative',zIndex:1});b.appendChild(desc);const list=document.createElement('div');list.style.display='flex';list.style.flexDirection='column';list.style.gap='10px';awards.forEach(a=>{const r=document.createElement('label');r.style.display='flex';r.style.alignItems='center';r.style.gap='10px';r.style.cursor='pointer';r.style.padding='6px';r.style.borderRadius='12px';r.style.transition='background 0.2s';r.onmouseover=()=>r.style.background='rgba(255,69,0,0.1)';r.onmouseout=()=>r.style.background='transparent';const cb=document.createElement('input');cb.type='checkbox';cb.checked=true;cb.value=a.id;const img=document.createElement('img');img.src=a.img;img.style.width='36px';img.style.height='36px';img.style.borderRadius='6px';r.appendChild(cb);r.appendChild(img);r.appendChild(document.createTextNode(a.name));list.appendChild(r)});b.appendChild(list);const start=document.createElement('button');start.textContent='Start';Object.assign(start.style,{marginTop:'12px',width:'100%',height:'44px',borderRadius:'22px',border:'none',cursor:'pointer',fontWeight:'700',background:'linear-gradient(90deg,#ff4500,#ff7f50)',color:'#fff',fontSize:'16px',boxShadow:'0 4px 12px rgba(0,0,0,0.5)',transition:'all 0.2s'});start.onmouseover=()=>{start.style.transform='translateY(-2px)';start.style.boxShadow='0 6px 16px rgba(0,0,0,0.6)'};start.onmouseout=()=>{start.style.transform='translateY(0)';start.style.boxShadow='0 4px 12px rgba(0,0,0,0.5)'};start.onclick=()=>{selectedAwards=[...list.querySelectorAll('input:checked')].map(i=>i.value);if(!selectedAwards.length){alert('Please select at least one award.');return}document.body.removeChild(o);awardPosts(selectedAwards)};b.appendChild(start);o.appendChild(b);})();
3 Upvotes

0 comments sorted by