Skip to content

实现 inject into - #711

Merged
CodFrm merged 7 commits into
mainfrom
develop/inject-into
Sep 10, 2025
Merged

CodFrm merged 7 commits into
mainfrom
develop/inject-into

Conversation

@CodFrm

@CodFrm CodFrm commented Sep 5, 2025

Copy link
Copy Markdown
Member

#681

实现 inject into,可以让脚本运行到content页面,让脚本绕过页面的CSP策略

TODO:

  • early-start 脚本暂不支持
  • content处代码逻辑较乱需要重构整理

@CodFrm CodFrm mentioned this pull request Sep 5, 2025
@CodFrm
CodFrm requested a review from Copilot September 5, 2025 11:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements "inject into" functionality that allows user scripts to run in the content script environment instead of the page context, enabling scripts to bypass CSP (Content Security Policy) restrictions while maintaining document access.

Key changes:

  • Added inject-into: content metadata support for directing scripts to the content environment
  • Extracted script execution logic into a reusable ScriptExecutor class
  • Modified the Chrome extension registration to use chrome.userScripts for both content and inject scripts

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/inject.ts Refactored to use new ScriptExecutor class for script execution
src/content.ts Added ScriptExecutor integration and message handling for content scripts
src/app/service/service_worker/runtime.ts Updated Chrome extension registration to use userScripts API and handle inject-into metadata
src/app/service/service_worker/client.ts Updated type imports for script loading
src/app/service/content/utils.ts Added utility function to detect inject-into content scripts
src/app/service/content/script_executor.ts New class containing extracted script execution logic
src/app/service/content/inject.ts Refactored to delegate script execution to ScriptExecutor
src/app/service/content/content.ts Added content script filtering and ScriptExecutor integration
packages/message/server.ts Enhanced Server class to support multiple message handlers
example/inject-into.js Example script demonstrating inject-into content usage

Comment thread src/inject.ts Resolved