Fontz Quiz Timer & Keyboard Shortcuts

Adds stopwatch to quiz pages; use Ctrl+S to submit and continue on quiz and quiz answer pages

当前为 2015-09-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fontz Quiz Timer & Keyboard Shortcuts
  3. // @namespace http://idlewords.net
  4. // @description Adds stopwatch to quiz pages; use Ctrl+S to submit and continue on quiz and quiz answer pages
  5. // @include http://50.116.7.11:9998/learningQuizController_turk/quiz
  6. // @include http://50.116.7.11:9998/learningQuizController_turk/quiz_answer
  7. // @include http://50.116.7.11:9998/learningQuizController_turk/main_menu
  8. // @version 0.2
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js
  10. // @require https://greasyfork.org/scripts/12377-timecircles/code/TimeCircles.js?version=73868
  11. // @grant GM_log
  12. // ==/UserScript==
  13.  
  14. this.$ = this.jQuery = jQuery.noConflict(true);
  15.  
  16. var keycode = 83; // 83 = S. Change this to a valid code from http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes to change the keyboard shortcut
  17.  
  18. $(document).ready(function() {
  19. if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/quiz') {
  20. $("head").append(
  21. $("<link></link>")
  22. .attr('rel', 'stylesheet')
  23. .attr('href', 'https://raw.githubusercontent.com/wimbarelds/TimeCircles/master/inc/TimeCircles.css')
  24. .attr('type', 'text/css')
  25. );
  26. $("div[align='right']").after(
  27. $("<div></div>")
  28. .css({'height': '200px', 'width': '500'})
  29. .addClass('timer')
  30. );
  31. $(".timer").TimeCircles({
  32. time: {
  33. Days: { show: false },
  34. Hours: { show: false },
  35. Minutes: { color: "#BBFFBB" },
  36. Seconds: { color: "#FF9999" }
  37. }
  38. });
  39. $(document).keydown(function(event) {
  40. if (event.which == 83 && event.ctrlKey) {
  41. event.preventDefault();
  42. $("#submitButton").click();
  43. } else if (event.which == 89 || event.which == 49 || event.which == 97) {
  44. event.preventDefault();
  45. $("#deformfield1-0").prop('checked', true);
  46. } else if (event.which == 78 || event.which == 50 || event.which == 98) {
  47. event.preventDefault();
  48. $("#deformfield1-1").prop('checked', true);
  49. }
  50. });
  51. } else if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/quiz_answer'){
  52. $(document).keydown(function(event) {
  53. if (event.which == keycode && event.ctrlKey) {
  54. event.preventDefault();
  55. $("input[name='Continue']").click();
  56. }
  57. });
  58. }
  59. });
  60.  
  61. $(window).load(function() {
  62. if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/main_menu') {
  63. setTimeout(function(){$('div#bodycontainer p').eq(0).before('Questions Answered: ' + $('circle').length);},200);
  64. }
  65. });