Duolingo Speedy Timed Practice

Duolingo - Speedier Timed Practice

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Duolingo Speedy Timed Practice
// @namespace    mog86uk-duo-speedy-timed-practice
// @version      1.0
// @description  Duolingo - Speedier Timed Practice
// @author       mog86uk (aka. testmoogle)
// @match        https://www.duolingo.com
// @match        https://www.duolingo.com/practice
// @match        https://www.duolingo.com/skill/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
// @grant        none
// @run-at       document-idle
// @noframes
// ==/UserScript==

(function() {
    'use strict';
    var $clonedResultBar;
    var speedyToggle = 0;
    var timerSpeedy;
    var timerCheckPageUrl;

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }

    jQuery.noConflict();
    jQuery(document).ready(function($) {

        addGlobalStyle('#duplicateResultBar div.PYCF5 * {color:#BBB!important;}');
        addGlobalStyle('#duplicateResultBar div._2KMvD._3nzjY {cursor:help;}');
        //addGlobalStyle('#duplicateResultBar {bottom:120px!important;height:120px!important;}');

        function Speedy() {
            if (!$('button._1pp2C._1MQOP._3qSMp._3cu46.T6NVk._27uC9').length) {
                if (!$('button[data-test="player-skip"]').length &&
                    $('button._3XJPq._1MQOP._3qSMp._3cu46._27uC9:enabled').length) {

                    if ($('#duplicateResultBar').length) {
                        $('#duplicateResultBar').remove();
                    }

                    $clonedResultBar =  $('div._1sntG').clone().prop('id', 'duplicateResultBar');
                    $('div._1sntG').after($clonedResultBar);
                    $('#duplicateResultBar button._3XJPq._1MQOP._3qSMp._3cu46._27uC9').remove();
                    $('#duplicateResultBar div._2KMvD._3nzjY')
                        .attr('title', 'Click to SKIP the current question')
                        .on('click', function(){$('button[data-test="player-skip"]').click();});

                    $('button._3XJPq._1MQOP._3qSMp._3cu46._27uC9').click();
                }
            }
            else {
                if (!$('button[data-test="secondary-button"]').length) {
                    if ($('#duplicateResultBar').length) {
                        $('#duplicateResultBar').remove();
                    }
                }
            }
        }

        function CheckPageUrl() {
            if (/^https:\/\/www\.duolingo\.com\/(practice|skill\/.+\/.+\/practice)/.test(window.location.href)) {
                if (speedyToggle === 0) {
                    window.clearInterval(timerSpeedy);
                    timerSpeedy = window.setInterval(Speedy, 50);
                    speedyToggle = 1;
                }
            }
            else {
                if (speedyToggle === 1) {
                    window.clearInterval(timerSpeedy);
                    speedyToggle = 0;
                }
            }
        }
        timerCheckPageUrl = window.setInterval(CheckPageUrl, 2000);
    });
})();