Twitter Script

helps with the twitter event stuff

当前为 2014-10-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Twitter Script
  3. // @version 0.2
  4. // @description helps with the twitter event stuff
  5. // @author Tjololo12
  6. // @match https://s3.amazonaws.com/eventeval-akiai7vktywrmkata7ra/Hits_EventEval/*
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/710
  10. // ==/UserScript==
  11.  
  12. var buttons = document.getElementsByTagName("button");
  13. var index = buttons.length;
  14. var isButtonClicked = false;
  15. var isTyping = false;
  16. var index = 0;
  17.  
  18. document.onkeydown = showkeycode;
  19.  
  20. function stopTyping (){
  21. isTyping = false;
  22. }
  23.  
  24. function showkeycode(evt){
  25. var keycode = evt.keyCode;
  26. console.log(keycode);
  27. switch (keycode) {
  28. case 192: //`
  29. var textbox = document.getElementById("topic"+(index+1)+"-sum");
  30. var texted = true;
  31. if (textbox){
  32. var text = textbox.value;
  33. if (text.length == 0){
  34. if (textbox.style.display === 'block')
  35. texted = false;
  36. }
  37. }
  38. if (!isButtonClicked && texted){
  39. isButtonClicked = true;
  40. if (index == buttons.length - 1){
  41. if (confirm("Are you sure you want to submit?"))
  42. buttons[index].click();
  43. }
  44. else
  45. buttons[index].click();
  46. }
  47. else{
  48. if (isButtonClicked)
  49. alert("Choose an answer by pressing 1, 2, or 3");
  50. if (!texted)
  51. alert("Make sure to enter a few keywords in the box");
  52. }
  53. break;
  54. case 49: //1
  55. if (isButtonClicked && !isTyping){
  56. document.getElementById("topic"+(index+1)+"-1").click();
  57. document.getElementById("topic"+(index+1)+"-sum").focus();
  58. document.getElementById("topic"+(index+1)+"-sum").onblur=function(){stopTyping};
  59. isTyping = true;
  60. isButtonClicked = false;
  61. index += 1;
  62. }
  63. else
  64. alert("Hit ` to open the tweet link before selecting an answer.");
  65. break;
  66. case 97: //numpad 1
  67. if (isButtonClicked && !isTyping){
  68. document.getElementById("topic"+(index+1)+"-1").click();
  69. document.getElementById("topic"+(index+1)+"-sum").focus();
  70. isButtonClicked = false;
  71. index += 1;
  72. }
  73. else
  74. alert("Hit ` to open the tweet link before selecting an answer.");
  75. break;
  76. case 50: //2
  77. if (isButtonClicked && !isTyping){
  78. document.getElementById("topic"+(index+1)+"-0").click();
  79. isButtonClicked = false;
  80. index += 1;
  81. }
  82. else
  83. alert("Hit ` to open the tweet link before selecting an answer.");
  84. break;
  85. case 98: //numpad 2
  86. if (isButtonClicked && !isTyping){
  87. document.getElementById("topic"+(index+1)+"-0").click();
  88. isButtonClicked = false;
  89. index += 1;
  90. }
  91. else
  92. alert("Hit ` to open the tweet link before selecting an answer.");
  93. break;
  94. case 51: //3
  95. if (isButtonClicked && !isTyping){
  96. document.getElementById("topic"+(index+1)+"-2").click();
  97. isButtonClicked = false;
  98. index += 1;
  99. }
  100. else
  101. alert("Hit ` to open the tweet link before selecting an answer.");
  102. break;
  103. case 99: //numpad 3
  104. if (isButtonClicked && !isTyping){
  105. document.getElementById("topic"+(index+1)+"-2").click();
  106. isButtonClicked = false;
  107. index += 1;
  108. }
  109. else
  110. alert("Hit ` to open the tweet link before selecting an answer.");
  111. break;
  112. default: break;
  113. }
  114. }