请问,JS脚本中,怎么把引号里的括号当做字符串文本处理

代码如下,是我抄来的,作用是替换文本汉化网页
就是开头这个(RC)这行不生效,我试着在括号前面加一个反斜杠没成功,请问应该如何让它被替换成中文呢?
多谢各位大佬啦!!!QvQ

(function() {
    'use strict';

    const i18n = new Map([
        ['When this unit is placed on (RC) from hand', '这个单位从手牌登场到R时'],
        ['and put it into your drop if it isn\'t', '不是的话,放置到弃牌区'],
        ['Diabolos, "Violence" Bruce', '魔惧会 “暴虐” 布鲁斯'],
    ])

    replaceText(document.body)

    const bodyObserver = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(addedNode => replaceText(addedNode))
        })
    })
    bodyObserver.observe(document.body, { childList: true, subtree: true })

    function replaceText(node) {
        nodeForEach(node).forEach(htmlnode => {
            i18n.forEach((value, index) => {
                // includes可直接使用 === 以提高匹配精度
                const textReg = new RegExp(index, 'g')
                if (htmlnode instanceof Text && htmlnode.nodeValue.includes(index)) {
                    htmlnode.nodeValue = htmlnode.nodeValue.replace(textReg, value)}
                else if (htmlnode instanceof HTMLInputElement && htmlnode.value.includes(index)) {
                    htmlnode.value = htmlnode.value.replace(textReg, value)}
            })
        })
    }

    function nodeForEach(node) {
        const list = []
        if (node.childNodes.length === 0) list.push(node)
        else {
            node.childNodes.forEach(child => {
                if (child.childNodes.length === 0) list.push(child)
                else list.push(...nodeForEach(child))
            })
        }
        return list
    }
})();

()是正则的关键字,分组用的,所以需要转义才能匹配()字符。而不是作为分组。但是转义后,又和你的htmlnode.nodeValue.includes代码冲突了。因为内容变为了\(RC\),和原始内容(RC)不匹配,去掉includes就可以了。如下

img

解决了你的问题能点个采纳吗,谢谢~

When this unit is placed on (RC) from hand
and put it into your drop if it isn't
Diabolos, "Violence" Bruce
<script>
    (function () {
        'use strict';
        const i18n = new Map([////////这里注意转义(),需要2个\\,因为最后需要内容为\(,直接用\(没有这种转义字符,会变为(内容,又无效了
            ['When this unit is placed on \\(RC\\) from hand', '这个单位从手牌登场到R时'],
            ['and put it into your drop if it isn\'t', '不是的话,放置到弃牌区'],
            ['Diabolos, "Violence" Bruce', '魔惧会 “暴虐” 布鲁斯'],
        ])
        replaceText(document.body)
        const bodyObserver = new MutationObserver(mutations => {
            mutations.forEach(mutation => {
                mutation.addedNodes.forEach(addedNode => replaceText(addedNode))
            })
        })
        bodyObserver.observe(document.body, { childList: true, subtree: true })
        function replaceText(node) {
            nodeForEach(node).forEach(htmlnode => {
                i18n.forEach((value, index) => {
                    const textReg = new RegExp(index, 'g')
                    if (htmlnode instanceof Text ) {//去掉includes
                        htmlnode.nodeValue = htmlnode.nodeValue.replace(textReg, value)
                    }
                    else if (htmlnode instanceof HTMLInputElement ) {//去掉includes
                        htmlnode.value = htmlnode.value.replace(textReg, value)
                    }
                })
            })
        }
        function nodeForEach(node) {
            const list = []
            if (node.childNodes.length === 0) list.push(node)
            else {
                node.childNodes.forEach(child => {
                    if (child.childNodes.length === 0) list.push(child)
                    else list.push(...nodeForEach(child))
                })
            }
            return list
        }
    })();

</script>

报什么错?