docs/en/docs/rules/cssAppend.md
The cssAppend protocol is used to insert specified content at the end of an existing CSS-type response body.
Effective Condition: Only takes effect on responses with a
content-typeheader containinghtmlorcss, and a status code that includes a response body (e.g.,200/500, etc.).⚠️ Note: Requests without a response body, such as
204,304, are not affected.HTML pages will automatically be wrapped in
<style>...</style>.
With the cssAppend protocol, you can:
cssAppend supports multiple ways to specify the content to be appended:
Write the CSS content to be appended directly in the rule.
# No spaces or line breaks are allowed inside the parentheses of `value`.
pattern cssAppend://(value) [lineProps...] [filters...]
Example:
www.example.com/index.html cssAppend://(.custom-btn{background:red;})
Use this method when the CSS content to be appended contains spaces, line breaks, or needs to be reused.
pattern cssAppend://{custom-key} [lineProps...] [filters...]
``` custom-key
.dark-mode {
background: #333;
color: #fff;
}
```
Reference CSS content pre-defined in the Values panel (central configuration area).
pattern cssAppend://{key-of-values} [lineProps...] [filters...]
Prerequisite: A key named key-of-values with CSS content as its value must exist in Values.
Use Whistle's temporary file feature when content needs frequent editing.
pattern cssAppend://temp.css
Steps:
Command (Mac) / Ctrl (Windows)cssAppend://temp.cssSave to saveAfter saving, the rule will automatically change to a format similar to this:
https://example.com/test.css cssAppend://temp/11adb9c9e1142df67b30d7646ec59bcd34c855d9011d1a2405c7fc2dfc94568d.css
To edit again, click the temporary file link in the same way.
Load the CSS content to be appended from a local file or remote URL.
# Load from a local file
pattern cssAppend:///User/xxx/custom.css
# Load from a remote URL (supports http and https)
pattern cssAppend://https://cdn.example.com/styles/override.css
| Parameter | Required | Description & Examples |
|---|---|---|
| pattern | Yes | Expression used to match the request URL. |
| • Supports domains, paths, wildcards, regular expressions. | ||
| • See Matching Pattern Documentation for details. | ||
| value | Yes | The CSS content to be appended, supporting multiple formats: |
| • Plain CSS code text | ||
| • Supports references from local files, remote URLs, inline, embedded, and Values | ||
| lineProps | No | Sets additional properties for the rule. |
• Example: lineProps://important can increase this rule's priority. | ||
| • See lineProps Documentation for details. | ||
| filters | No | Optional filter conditions for precise control over when the rule takes effect. |
| • Can match request URL, method, headers, body content. | ||
| • Can match response status code, headers. | ||
| • See Filters Documentation for details. |
Special Notes:
content-type response header contains css.204, 304.www.example.com/responsive.css cssAppend://{test.css}
``` test.css
@media (max-width: 768px) {
.sidebar { display: none; }
.main-content { width: 100%; }
}
```
cdn.example.com/bootstrap.min.css cssAppend://{test2.css}
``` test2.css
/* Override Bootstrap default styles */
.btn-primary { background-color: #007bff !important; }
.container { max-width: 1400px; }
```
www.example.com/print.css cssAppend://{test3.css}
``` test3.css
@media print {
.no-print { display: none; }
a::after { content: " (" attr(href) ")"; }
}
```
Prepend To Body): resPrependPrepend HTML To Body, response type must be text/html): htmlPrependPrepend CSS To Body, response type must be text/html or text/css): cssPrependPrepend JS To Body, response type must be text/html, text/css, or application/javascript): jsPrependReplace Body): resBodyReplace Body, response type must be text/html): htmlBodyReplace Body, response type must be text/html or text/css): cssBodyReplace Body, response type must be text/html, text/css, or application/javascript): jsBodyAppend To Body): resAppendAppend HTML To Body, response type must be text/html): htmlAppendAppend CSS To Body, response type must be text/html or text/css): cssAppendAppend JS To Body, response type must be text/html, text/css, or application/javascript): jsAppendModify Body Text): resReplaceModify Form/JSON): resMergeDelete Form/JSON): delete://resBody.xxx