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-12 提交的版本,檢視 最新版本

  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. // @version 0.1
  8. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js
  9. // @require https://greasyfork.org/scripts/12377-timecircles/code/TimeCircles.js?version=73868
  10. // @grant GM_log
  11. // ==/UserScript==
  12.  
  13. this.$ = this.jQuery = jQuery.noConflict(true);
  14.  
  15. 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
  16.  
  17. $(document).ready(function() {
  18. if (document.location.href.search('answer') < 0) {
  19. $("head").append(
  20. $("<link></link>")
  21. .attr('rel', 'stylesheet')
  22. .attr('href', 'http://git.wimbarelds.nl/TimeCircles/inc/TimeCircles.css')
  23. .attr('type', 'text/css')
  24. );
  25. $("div[align='right']").after(
  26. $("<div></div>")
  27. .css({'height': '200px', 'width': '500'})
  28. .addClass('timer')
  29. );
  30. $(".timer").TimeCircles({
  31. time: {
  32. Days: { show: false },
  33. Hours: { show: false },
  34. Minutes: { color: "#BBFFBB" },
  35. Seconds: { color: "#FF9999" }
  36. }
  37. });
  38. $(document).keydown(function(event) {
  39. if (event.which == 83 && event.ctrlKey) {
  40. event.preventDefault();
  41. $("#submitButton").click();
  42. } else if (event.which == 89) {
  43. event.preventDefault();
  44. $("#deformfield1-0").prop('checked', true);
  45. } else if (event.which == 78) {
  46. event.preventDefault();
  47. $("#deformfield1-1").prop('checked', true);
  48. }
  49. });
  50. } else {
  51. $(document).keydown(function(event) {
  52. if (event.which == keycode && event.ctrlKey) {
  53. event.preventDefault();
  54. $("input[name='Continue']").click();
  55. }
  56. });
  57. }
  58. });