Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Javascript (and jQuery) bot for "Stack Egg" on Stack Exchange (April Fools 2015).
- //Paste this into the console of your browser. It has only been tested in Google Chrome.
- //Stop it with clearInterval(egger)
- // Original by Calvin's Hobbies
- (function () {
- function vote() {
- var attr = {
- 'questions': {
- 'val': 4,
- 'btn': 'Ask'
- },
- 'answers': {
- 'val': 4,
- 'btn': 'Answer'
- },
- 'users': {
- 'val': 4,
- 'btn': 'Upvote'
- },
- 'quality': {
- 'val': 4,
- 'btn': 'Downvote'
- },
- }
- var red = '';
- $.each(attr, function(key, val) {
- var s = $('#egg-stat-' + key)
- if (s.length > 0) {
- s = parseInt(s.attr('title')[0])
- var v = (isNaN(s) ? -1 : s);
- val.val = v;
- if(v < 0) red = key;
- attr[key] = val;
- }
- });
- // Maximize Ask, then Answer, then Quality, then Users. Upvote if a question is in red.
- //determine what button to press, press Ask by default
- var btn;
- if(red != '')
- {
- btn = attr[red].btn;
- }
- else
- {
- if(attr['questions'].val < 4)
- btn = attr['questions'].btn;
- else if(attr['questions'].val > attr['answers'].val)
- btn = attr['answers'].btn;
- else if(attr['users'].val > 0 && attr['quality'].val < attr['answers'].val)
- btn = attr['quality'].btn;
- else if(attr['users'].val < 4)
- btn = attr['users'].btn;
- else
- btn = attr['questions'].btn;
- }
- //click the button selected, or click Continue then Restart if button not found
- var clickPriority = [btn, 'Continue', 'Restart'], b = $('button')
- for(var i = 0; i < clickPriority.length; i++) {
- b.each(function() {
- var t = $(this)
- if (t.text() == clickPriority[i]) {
- t.click()
- console.log('Voted for ' + clickPriority[i] + ' at ' + (counter * 10).toString() + ' seconds in.')
- i = clickPriority.length
- }
- })
- }
- ++counter
- }
- counter = 0
- vote()
- egger = setInterval(vote, 10000) //10 seconds instead of 20 ensures there are no sync problems
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement