Guardian Crossword Better Checker

Check Guardian (Cryptic) Crosswords

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Guardian Crossword Better Checker
// @license      MIT
// @namespace    https://greasyfork.org/en/users/890062-garyt
// @version      2025-11-01
// @description  Check Guardian (Cryptic) Crosswords
// @author       GaryT
// @match        https://www.theguardian.com/crosswords/*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=theguardian.com
// @grant        none
// ==/UserScript==

function chklist(list,results){
    for (let i = 0; i < list.length; i++) {
        results.clues++;
        let ans = list[i].querySelector("span.dcr-1i5wt9b");
        if (ans.textContent.includes("Answer correct.")){
            results.correct++;
            list[i].style.color = 'green';
        } else {
            list[i].style.color = 'red';
        }
    }
}

function chkclues(ser,serno){
    const sel = "-hints-crosswords/"+ser+"/"+serno;
    const aclist = document.getElementById("across"+sel).children;
    const dnlist = document.getElementById("down"+sel).children;
    let results = { correct : 0, clues : 0 };
    chklist(aclist,results);
    chklist(dnlist,results);
    if (results.correct == results.clues){
        alert("All Correct!")
    } else {
        alert(results.correct + " of " + results.clues + " correct");
    }
}

(function() {
    'use strict';
    console.log("GTGCCheck");
    const crozzi = "https://www.theguardian.com/crosswords/"
    const gcURL = window.location.href;
    const esccroz = crozzi.replace(/\./g,"\\.");
    const gcRE = new RegExp(esccroz+'(.*)/([0-9]+)');
    const gcmatch = gcRE.exec(gcURL);
    const series = gcmatch[1]
    const this1 = parseInt(gcmatch[2]);
    const title = document.querySelector("h1.dcr-uc7bn6");
    const cluecon0 = document.querySelector("button.dcr-hdcfwb"); // adding buttons here fails?
    cluecon0.addEventListener('click', function() {
        const chkbutstate = cluecon0.textContent;
        if ( chkbutstate === "Confirm Check All") {
            setTimeout(() => {
                chkclues(series,this1);
            }, 300);
        }
    });
})();