Updated Quizlet Micromatch bot

Win micromatch in less than a second! this is based off of the original script by , but basically all of the code has been replaced by my own

当前为 2019-09-21 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Updated Quizlet Micromatch bot
// @namespace    BenjaminHinchliff
// @version      0.1
// @description  Win micromatch in less than a second! this is based off of the original script by , but basically all of the code has been replaced by my own
// @author       You
// @match        https://quizlet.com/*/match*
// @grant        none
// ==/UserScript==

// this is based off of the original script for this,
// but basically all of the code has been replaced by my own

// a little function to allow the program to click on elements
function clickEvent(element) {
    let eve = new CustomEvent("pointerdown", { bubbles: true });
    element.dispatchEvent(eve);
}

let rawTerms = Quizlet.matchModeData.terms;
let terms = {};
// get terms from Quizlet object (a global variable because I only want to retrive it once)
for (let i = 0; i < rawTerms.length; i++) {
    terms[rawTerms[i].word] = rawTerms[i].definition;
}

// wait until user presses start
document.onclick = ()=>{
    // get all the nodes and store them in a variable to avoid re-querying nodes (I know it's live shut up)
    let nodes = document.querySelector(".MatchModeQuestionGridBoard-tiles").childNodes;
    for (let i = 0; i < nodes.length; i++) {
        // get term
        let search = nodes[i].childNodes[0].childNodes[0].childNodes[0].childNodes[0].innerHTML;
        // match with definition
        let dictionaryResult = terms[search];
        if(dictionaryResult) {
            // find term in nodes and send click events
            for (let j = 0; j < nodes.length; j++) {
                if (nodes[j].innerHTML.includes(dictionaryResult)) {
                    setTimeout(() => {
                        clickEvent(nodes[i].childNodes[0]);
                        clickEvent(nodes[j].childNodes[0]);
                    },
                    i * 50); // this is only here because quizlet doesn't allow score below 0.5 seconds and this roughly comes out to 0.5
                }
            }
        }
    }
};