✨ 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)
|
||||
|
||||
14
dist/cli.js
vendored
14
dist/cli.js
vendored
@@ -135,7 +135,7 @@ var windows = [
|
||||
dark_mode: false,
|
||||
activation_shortcut: "",
|
||||
disabled_web_shortcuts: false,
|
||||
hide_on_close: false
|
||||
hide_on_close: true
|
||||
}
|
||||
];
|
||||
var user_agent = {
|
||||
@@ -785,6 +785,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
||||
height: 780,
|
||||
width: 1200,
|
||||
fullscreen: false,
|
||||
resizable: true,
|
||||
hideTitleBar: false,
|
||||
alwaysOnTop: false,
|
||||
appVersion: '1.0.0',
|
||||
@@ -992,7 +993,16 @@ program
|
||||
.option('--fullscreen', 'Start in full screen', DEFAULT_PAKE_OPTIONS.fullscreen)
|
||||
.option('--hide-title-bar', 'For Mac, hide title bar', DEFAULT_PAKE_OPTIONS.hideTitleBar)
|
||||
.option('--multi-arch', 'For Mac, both Intel and M1', DEFAULT_PAKE_OPTIONS.multiArch)
|
||||
.option('--inject <url...>', 'Injection of .js or .css files', DEFAULT_PAKE_OPTIONS.inject)
|
||||
.option('--inject <./style.css,./script.js,...>', 'Injection of .js or .css files', (val, previous) => {
|
||||
if (!val)
|
||||
return DEFAULT_PAKE_OPTIONS.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_PAKE_OPTIONS.inject)
|
||||
.option('--debug', 'Debug build and more output', DEFAULT_PAKE_OPTIONS.debug)
|
||||
.addOption(new Option('--proxy-url <url>', 'Proxy URL for all network requests').default(DEFAULT_PAKE_OPTIONS.proxyUrl).hideHelp())
|
||||
.addOption(new Option('--user-agent <string>', 'Custom user agent').default(DEFAULT_PAKE_OPTIONS.userAgent).hideHelp())
|
||||
|
||||
Reference in New Issue
Block a user