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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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
                }
            }
        }
    }
};