Twitter Script

helps with the twitter event stuff

2014-10-24 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Twitter Script
// @version      0.2
// @description  helps with the twitter event stuff
// @author       Tjololo12
// @match        https://s3.amazonaws.com/eventeval-akiai7vktywrmkata7ra/Hits_EventEval/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// @grant        none
// @namespace https://greasyfork.org/users/710
// ==/UserScript==

var buttons = document.getElementsByTagName("button");
var index = buttons.length;
var isButtonClicked = false;
var isTyping = false;
var index = 0;

document.onkeydown = showkeycode;

function stopTyping (){
    isTyping = false;
}

function showkeycode(evt){
        var keycode = evt.keyCode;
        console.log(keycode);
        switch (keycode) {
            case 192: //`
                var textbox = document.getElementById("topic"+(index+1)+"-sum");
                var texted = true;
                if (textbox){
                    var text = textbox.value;
                    if (text.length == 0){
                        if (textbox.style.display === 'block')
                            texted = false;
                    }
                }
                if (!isButtonClicked && texted){
                    isButtonClicked = true;
                    if (index == buttons.length - 1){
                        if (confirm("Are you sure you want to submit?"))
                            buttons[index].click();
                    }
                    else
                    	buttons[index].click();
                }
                else{
                    if (isButtonClicked)
                        alert("Choose an answer by pressing 1, 2, or 3");
                    if (!texted)
                        alert("Make sure to enter a few keywords in the box");
                }
                break;
            case 49: //1
                if (isButtonClicked && !isTyping){
                    document.getElementById("topic"+(index+1)+"-1").click();
                    document.getElementById("topic"+(index+1)+"-sum").focus();
                    document.getElementById("topic"+(index+1)+"-sum").onblur=function(){stopTyping};
                    isTyping = true;
                    isButtonClicked = false;
                    index += 1;
                }
                else
                    alert("Hit ` to open the tweet link before selecting an answer.");
                break;
            case 97: //numpad 1
                if (isButtonClicked && !isTyping){
                    document.getElementById("topic"+(index+1)+"-1").click();
                    document.getElementById("topic"+(index+1)+"-sum").focus();
                    isButtonClicked = false;
                    index += 1;
                }
                else
                    alert("Hit ` to open the tweet link before selecting an answer.");
                break;
            case 50: //2
                if (isButtonClicked && !isTyping){
                    document.getElementById("topic"+(index+1)+"-0").click();
                    isButtonClicked = false;
                    index += 1;
                }
                else
                    alert("Hit ` to open the tweet link before selecting an answer.");
                break;
            case 98: //numpad 2
                if (isButtonClicked && !isTyping){
                    document.getElementById("topic"+(index+1)+"-0").click();
                    isButtonClicked = false;
                    index += 1;
                }
                else
                    alert("Hit ` to open the tweet link before selecting an answer.");
                break;
            case 51: //3
                if (isButtonClicked && !isTyping){
                    document.getElementById("topic"+(index+1)+"-2").click();
                    isButtonClicked = false;
                    index += 1;
                }
                else
                    alert("Hit ` to open the tweet link before selecting an answer.");
                break;
            case 99: //numpad 3
                if (isButtonClicked && !isTyping){
                    document.getElementById("topic"+(index+1)+"-2").click();
                    isButtonClicked = false;
                    index += 1;
                }
                else
                    alert("Hit ` to open the tweet link before selecting an answer.");
                break;
            default: break;
        }
}