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-14 提交的版本,查看 最新版本

  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.3
  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. // @resource customCSS https://raw.githubusercontent.com/wimbarelds/TimeCircles/master/inc/TimeCircles.css
  12. // @grant GM_addStyle
  13. // @grant GM_getResourceText
  14. // ==/UserScript==
  15.  
  16. this.$ = this.jQuery = jQuery.noConflict(true);
  17.  
  18. 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
  19.  
  20. var newCSS = GM_getResourceText ("customCSS");
  21. GM_addStyle (newCSS);
  22.  
  23. $(document).ready(function() {
  24. if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/quiz') {
  25. /*$("head").append(
  26. $("<link></link>")
  27. .attr('rel', 'stylesheet')
  28. .attr('href', '')
  29. .attr('type', 'text/css')
  30. );*/
  31. $("div[align='right']").after(
  32. $("<div></div>")
  33. .css({'height': '200px', 'width': '500'})
  34. .addClass('timer')
  35. );
  36. $(".timer").TimeCircles({
  37. time: {
  38. Days: { show: false },
  39. Hours: { show: false },
  40. Minutes: { color: "#BBFFBB" },
  41. Seconds: { color: "#FF9999" }
  42. }
  43. });
  44. $(document).keydown(function(event) {
  45. if (event.which == 83 && event.ctrlKey) {
  46. event.preventDefault();
  47. $("#submitButton").click();
  48. } else if (event.which == 89 || event.which == 49 || event.which == 97) {
  49. event.preventDefault();
  50. $("#deformfield1-0").prop('checked', true);
  51. } else if (event.which == 78 || event.which == 50 || event.which == 98) {
  52. event.preventDefault();
  53. $("#deformfield1-1").prop('checked', true);
  54. }
  55. });
  56. } else if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/quiz_answer'){
  57. $(document).keydown(function(event) {
  58. if (event.which == keycode && event.ctrlKey) {
  59. event.preventDefault();
  60. $("input[name='Continue']").click();
  61. }
  62. });
  63. }
  64. });
  65.  
  66. $(window).load(function() {
  67. if (document.location.href == 'http://50.116.7.11:9998/learningQuizController_turk/main_menu') {
  68. setTimeout(function(){$('div#bodycontainer p').eq(0).before('Questions Answered: ' + $('circle').length);},1000);
  69. }
  70. });