Skip to content

Conversation

@cyfung1031
Copy link
Collaborator

概述 Descriptions

现时 dealScript 只针对引号和换行符
但实际转换不应如此

实际应用

            chrome.tabs.executeScript(sender.tabId!, {
              frameId: sender.frameId,
              code: `(function(){
                let temp = document.createElementNS("http://www.w3.org/1999/xhtml", "script");
                    temp.setAttribute('type', 'text/javascript');
                    temp.setAttribute('charset', 'UTF-8');
                    temp.textContent = "${script.code}";
                    temp.className = "injected-js";
                    document.documentElement.appendChild(temp);
                    temp.remove();
                }())`,
              runAt,
            });

改用原生方法 JSON.parse(string),浏览器内部API 自行判断如何「字串化」

例子 This is a "Apple".\n123\n\r456 => "This is a \\"Apple\\".\\n123\\n\\r456"

变更内容 Changes

截图 Screenshots

@cyfung1031 cyfung1031 marked this pull request as draft November 20, 2025 10:53
@cyfung1031 cyfung1031 marked this pull request as ready for review November 20, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant