1 1/2 hour until the deadline to submit and code is hit.
Results 1 to 40 of 211
Hybrid View
- 15 Jul. 2013 06:30pm #1
- 15 Jul. 2013 07:03pm #2
- 15 Jul. 2013 07:39pm #3
Final code...for now.
Spoiler:Code:// ==UserScript== // @author T3h Mule // @description Wins a contest lol // @name Contest Winner // @version 0.1.0 // @include http://www.gaiaonline.com/forum/* // @include http://gaiaonline.com/forum/* // @requre http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js // ==/UserScript== //Used jQuery because I'm lazy, and it looks pretty. //Lol. //Should I turn this into a giant class? //I have like no experience with classes, really. o_O //I should do that as a side project... function post(id){ $.ajax({ type: 'GET', url: 'http://www.gaiaonline.com/forum/compose/quickreply/new/'+ id +'/', dataType: 'json', //async: false, }).done(function(json){ if(json["show_captcha"]===true){ var captcha=window.showModalDialog('data:text/html;base64,PGh0bWw+CjxoZWFkPjwvaGVhZD4KPGJvZHk+CjxzY3JpcHQ+CmRvY3VtZW50LndyaXRlKCJEYW0gQ2FwdGNoYTo8YnIvPiIrd2luZG93LmRpYWxvZ0FyZ3VtZW50cyk7Cjwvc2NyaXB0Pgo8YnIvPgo8aW5wdXQgaWQ9ImNhcHRjaGEiIHR5cGU9InRleHQiLz4KPGlucHV0IGlkPSJzdWJtaXQiIHR5cGU9ImJ1dHRvbiIgdmFsdWU9IlN1Ym1pdCIgb25jbGljaz0id2luZG93LnJldHVyblZhbHVlID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ2NhcHRjaGEnKS52YWx1ZTsgd2luZG93LmNsb3NlKCk7Ij48YnIvPgo8aW5wdXQgdHlwZT0iYnV0dG9uIiB2YWx1ZT0iSSBjYW4gbm90IHJlYWQgdGhhdCIgb25jbGljaz0id2luZG93LnJldHVyblZhbHVlID0gJ25ldyc7IHdpbmRvdy5jbG9zZSgpOyI+PGJyLz4KPGlucHV0IHR5cGU9ImJ1dHRvbiIgdmFsdWU9IkkgZG8gbm90IGhhdmUgdGltZSBmb3IgdGhpcy4iIG9uY2xpY2s9IndpbmRvdy5yZXR1cm5WYWx1ZSA9ICcnOyB3aW5kb3cuY2xvc2UoKTsiPgo8L2JvZHk+CjwvaHRtbD4=','<img src="'+json['captcha_img']+'"/>',"dialogwidth: 350; dialogheight: 150; resizable: yes"); if(!captcha || captcha.length==0){ var abort=true; } else if(captcha=='new'){ var abort=true; setTimeout('post('+id+')',0); } else{ abort=false; var captchaKey=json["captcha_challenge"]; } } else{ var captcha=''; abort=false; } if(abort===false){ if(!captchaKey){ captchaKey=''; } var pc = 1; if(GM_getValue(id)){ pc = GM_getValue(id)+1; } GM_setValue(id, pc); var post = '[align=center]:ninja:\n'+ pc +'[/align]';//format post a little. Lol. $.ajax({ method: 'POST', dataType: 'json', async: false, data: 'nonce='+json['nonce']+'&recaptcha_response_field='+escape(captcha)+'&recaptcha_challenge_field='+captchaKey+'&message='+escape(post)+'&action_submit=submit', url: 'http://www.gaiaonline.com/forum/compose/ajaxentry/new/'+id+'/' }).done(function(data){ if(data['status']===true){ //alert('victory'); Debug. Whoops. } else{ if(confirm('Failed to complete post. Gaia said:\n\t"'+data['message']+'"\nWould you like to try again?')===true){ setTimeout('post('+id+')',0); } } }); } }); } function forumScanner(){ var thread; $.ajax({ type: 'GET', url: 'http://www.gaiaonline.com/mobileapp/forums/show/f.23', async: false, dataType: 'html', }).done(function(r){ var keywords = ['give away', 'giveaway', 'givaway', 'give-away', 'giving away'], threads = new Array(); //Array can be extended or condensed. Depends on what you want to do. xP $(r).find('.topic-left a').each(function(){ var $title = $(this).text(); var $id = $(this).attr('href').split('http://www.gaiaonline.com/mobileapp/forums/show/t.')[1] for(var i = 0; i<keywords.length; i++){ var keyword = keywords[i]; if($title.indexOf(keyword) != -1){ threads.push($id); } } }); if(threads.length > 0){ thread = threads[0]; } else{ thread = 36828231;//Use as default in case no giveaways are found. Feel free to change. } }); return thread; } function main(){ var thread = forumScanner(); post(thread); var wait = Math.random() * (10000 - 2500) + 2500;//Between 2.5 and 10 seconds. Can be modified as you wish. Protip: Change the values a bit, so that everyone isn't posting at the same rate. setTimeout(main, wait); } main();
Fixed the refresher so that the page doesn't have to reload.
Optional: Use forum pulse instead of mobile API
Spoiler:Code:function forumScanner(){ var thread; $.ajax({ type: 'GET', url: 'http://www.gaiaonline.com/forum/pulse?id=23&ts='+ new Date().getTime(), async: false, dataType: 'json', }).done(function(r){ var keywords = ['give away', 'giveaway', 'givaway', 'give-away', 'giving away'], threads = new Array(); //Array can be extended or condensed. Depends on what you want to do. xP for(var x in r){ var title = r[x].topic; var id = r[x].url.split('t.')[1]; id = id.split('/')[0]; for(var i = 0; i<keywords.length;i++){ var keyword = keywords[i]; if(title.indexOf(keyword) != -1){ threads.push(id); } } } if(threads.length > 0){ thread = threads[0]; } else{ thread = 36828231;//Use as default in case no giveaways are found. Feel free to change. } }); return thread; }
Tampermonkey users will need to include jQuery manually into the file. Check jquery.com for the link. Not sure about Firefox users. xD Didn't test in Firefox.Last edited by T3h Mule; 15 Jul. 2013 at 07:42pm.
D: I CAN'T THINK OF ANYTHING CLEVER
- 15 Jul. 2013 07:58pm #4
- 15 Jul. 2013 08:00pm #5
- 15 Jul. 2013 08:03pm #6
- 15 Jul. 2013 08:09pm #7
- 15 Jul. 2013 08:09pm #8
- 15 Jul. 2013 08:13pm #9
You won anyways since you actually submitted something. About to message you the account info.
For those curious, here's how I'd do it in Python (without any of the selection process, just the two functions)
First function uses forum pulse to get all the thread IDs through a generator, then you just use the post with session (it's copy pasted from a program I made so session would be a requests session) thread id, and the message.
Code:import requests import simplejson as json def get_threads(forum_id): uri = 'http://www.gaiaonline.com/forum/pulse?id={}'.format(forum_id) for thread_info in json.loads(requests.get(uri).content): yield thread_info['tid'] def post(session, tid, message): uri = 'http://www.gaiaonline.com/forum/compose/{}/new/{}' thread_info = session.get(uri.format('quickreply', tid)).json() post_data = { 'nonce': thread_info['nonce'], 'message': message, 'action_submit': 'submit', } session.post(uri.format('ajaxentry', tid), data=post_data).json()
Last edited by Tree; 15 Jul. 2013 at 08:17pm.
- 15 Jul. 2013 08:33pm #10
should this thread be moved now?
- 15 Jul. 2013 09:10pm #11
Mine could have been more simple, but I figured that the goal was posting AND getting gold from it, which is why I threw in the giveaway keywords. xP
Also: That account has so many items. o_O
Gonna slowly drain them over a few months, and then use the gold for hoarding. :'DD: I CAN'T THINK OF ANYTHING CLEVER