✨ Support more convenient inject js css
This commit is contained in:
9
bin/README.md
vendored
9
bin/README.md
vendored
@@ -245,8 +245,17 @@ Enable recursive copying. When the URL is a local file path, enabling this optio
|
||||
|
||||
Using `inject`, you can inject local absolute and relative path `css` and `js` files into the page you specify the `url` to customize it. For example, an adblock script that can be applied to any web page, or a `css` that optimizes the `UI` of a page, you can write it once to customize it. would only need to write the `app` once to generalize it to any other page.
|
||||
|
||||
Supports both comma-separated and multiple option formats:
|
||||
|
||||
```shell
|
||||
# Comma-separated (recommended)
|
||||
--inject ./tools/style.css,./tools/hotkey.js
|
||||
|
||||
# Multiple options
|
||||
--inject ./tools/style.css --inject ./tools/hotkey.js
|
||||
|
||||
# Single file
|
||||
--inject ./tools/style.css
|
||||
```
|
||||
|
||||
#### [proxy-url]
|
||||
|
||||
13
bin/README_CN.md
vendored
13
bin/README_CN.md
vendored
@@ -245,14 +245,19 @@ pake [url] [options]
|
||||
|
||||
#### [inject]
|
||||
|
||||
使用 `inject` 可以通过本地的绝对、相对路径的 `css` `js` 文件注入到你所指定 `url` 的页面中,从而为
|
||||
使用 `inject` 可以通过本地的绝对、相对路径的 `css` `js` 文件注入到你所指定 `url` 的页面中,从而为其做定制化改造。举个例子:一段可以通用到任何网页的广告屏蔽脚本,或者是优化页面 `UI` 展示的 `css`,你只需要书写一次可以将其通用到任何其他网页打包的 `app`。
|
||||
|
||||
其做定制化改造。举个例子:一段可以通用到任何网页的广告屏蔽脚本,或者是优化页面 `UI` 展的 `css`,你
|
||||
|
||||
只需要书写一次可以将其通用到任何其他网页打包的 `app`。
|
||||
支持逗号分隔和多个选项两种格式:
|
||||
|
||||
```shell
|
||||
# 逗号分隔(推荐)
|
||||
--inject ./tools/style.css,./tools/hotkey.js
|
||||
|
||||
# 多个选项
|
||||
--inject ./tools/style.css --inject ./tools/hotkey.js
|
||||
|
||||
# 单个文件
|
||||
--inject ./tools/style.css
|
||||
```
|
||||
|
||||
#### [proxy-url]
|
||||
|
||||
12
bin/cli.ts
vendored
12
bin/cli.ts
vendored
@@ -42,7 +42,17 @@ program
|
||||
.option(
|
||||
'--inject <./style.css,./script.js,...>',
|
||||
'Injection of .js or .css files',
|
||||
(val, previous) => (val ? val.split(',').map(item => item.trim()) : DEFAULT.inject),
|
||||
(val, previous) => {
|
||||
if (!val) return DEFAULT.inject;
|
||||
|
||||
// Split by comma and trim whitespace, filter out empty strings
|
||||
const files = val.split(',')
|
||||
.map(item => item.trim())
|
||||
.filter(item => item.length > 0);
|
||||
|
||||
// If previous values exist (from multiple --inject options), merge them
|
||||
return previous ? [...previous, ...files] : files;
|
||||
},
|
||||
DEFAULT.inject,
|
||||
)
|
||||
.option('--debug', 'Debug build and more output', DEFAULT.debug)
|
||||
|
||||
Reference in New Issue
Block a user