Duolingo Speedy Timed Practice

Duolingo - Speedier Timed Practice

当前为 2017-12-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Duolingo Speedy Timed Practice
  3. // @namespace mog86uk-duo-speedy-timed-practice
  4. // @version 1.0
  5. // @description Duolingo - Speedier Timed Practice
  6. // @author mog86uk (aka. testmoogle)
  7. // @match https://www.duolingo.com
  8. // @match https://www.duolingo.com/practice
  9. // @match https://www.duolingo.com/skill/*
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
  11. // @grant none
  12. // @run-at document-idle
  13. // @noframes
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18. var $clonedResultBar;
  19. var speedyToggle = 0;
  20. var timerSpeedy;
  21. var timerCheckPageUrl;
  22.  
  23. function addGlobalStyle(css) {
  24. var head, style;
  25. head = document.getElementsByTagName('head')[0];
  26. if (!head) { return; }
  27. style = document.createElement('style');
  28. style.type = 'text/css';
  29. style.innerHTML = css;
  30. head.appendChild(style);
  31. }
  32.  
  33. jQuery.noConflict();
  34. jQuery(document).ready(function($) {
  35.  
  36. addGlobalStyle('#duplicateResultBar div.PYCF5 * {color:#BBB!important;}');
  37. addGlobalStyle('#duplicateResultBar div._2KMvD._3nzjY {cursor:help;}');
  38. //addGlobalStyle('#duplicateResultBar {bottom:120px!important;height:120px!important;}');
  39.  
  40. function Speedy() {
  41. if (!$('button._1pp2C._1MQOP._3qSMp._3cu46.T6NVk._27uC9').length) {
  42. if (!$('button[data-test="player-skip"]').length &&
  43. $('button._3XJPq._1MQOP._3qSMp._3cu46._27uC9:enabled').length) {
  44.  
  45. if ($('#duplicateResultBar').length) {
  46. $('#duplicateResultBar').remove();
  47. }
  48.  
  49. $clonedResultBar = $('div._1sntG').clone().prop('id', 'duplicateResultBar');
  50. $('div._1sntG').after($clonedResultBar);
  51. $('#duplicateResultBar button._3XJPq._1MQOP._3qSMp._3cu46._27uC9').remove();
  52. $('#duplicateResultBar div._2KMvD._3nzjY')
  53. .attr('title', 'Click to SKIP the current question')
  54. .on('click', function(){$('button[data-test="player-skip"]').click();});
  55.  
  56. $('button._3XJPq._1MQOP._3qSMp._3cu46._27uC9').click();
  57. }
  58. }
  59. else {
  60. if (!$('button[data-test="secondary-button"]').length) {
  61. if ($('#duplicateResultBar').length) {
  62. $('#duplicateResultBar').remove();
  63. }
  64. }
  65. }
  66. }
  67.  
  68. function CheckPageUrl() {
  69. if (/^https:\/\/www\.duolingo\.com\/(practice|skill\/.+\/.+\/practice)/.test(window.location.href)) {
  70. if (speedyToggle === 0) {
  71. window.clearInterval(timerSpeedy);
  72. timerSpeedy = window.setInterval(Speedy, 50);
  73. speedyToggle = 1;
  74. }
  75. }
  76. else {
  77. if (speedyToggle === 1) {
  78. window.clearInterval(timerSpeedy);
  79. speedyToggle = 0;
  80. }
  81. }
  82. }
  83. timerCheckPageUrl = window.setInterval(CheckPageUrl, 2000);
  84. });
  85. })();