gooboo自动做题

gooboo自动做题!自用

< 腳本gooboo自动做题的回應

提問/評論

§
發表於:2025-05-01

如下修改,以计算"a^b"与"√a"表达式
//var question=$('.text-center.question-text')[0].innerText.replace(/[^0-9+\-*/\s]/g,'');
// ========== 核心修改开始 ==========
let question = $('.text-center.question-text')[0].innerText
.replace(/[^0-9+\-*/^\√\s]/g, '') // 允许^和√符号
.replace(/√(\d+)/g, 'Math.sqrt($1)') // 处理√数字 → Math.sqrt(数字)
.replace(/\^/g, '**'); // 处理次幂符号

// 示例转换:
// "2^3 + √4" → "2**3 + Math.sqrt(4)"
// "√9^2" → "Math.sqrt(9)**2"
// ========== 核心修改结束 ==========

發表回覆

登入以回覆

长期地址
遇到问题?请前往 GitHub 提 Issues。