Domain‑specific CSS Injector

Inject custom CSS per domain – works on iOS, iPadOS and desktop browsers.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
Nick Bakaka
今日安裝
1
安裝總數
3
評價
0 0 0
版本
1.0
建立日期
2026-01-05
更新日期
2026-01-05
尺寸
2.7 KB
授權條款
CC-ND-NA
腳本執行於

This script allows injection of CSS on a per‑domain basis and works on iOS/iPadOS Safari (via the native userscript support in Safari 15+), Chrome, Firefox, and all other browsers that support Userscripts.

How it works

@match *://*/*

The script runs on every page, giving you full control over which hosts receive CSS.

Domain‑specific configuration

hostRegex: A regular expression that tests the current hostname (window.location.hostname). css: Plain CSS rules to be injected. Separate rules with newlines; you can use any valid CSS, including media queries and !important. Injection

The helper injectCss creates a style element and appends it to the document head (or the root element if head is missing).

This works in all browsers that support Userscripts, including iOS Safari.

Customising

To add a new domain, insert another object into domainCssMap.

Example:

{
    hostRegex: /^shop\.example\.com$/i,
    css: `
        .product-grid { grid-template-columns: repeat(3,1fr) !important; }
    `
}

If you want a rule to apply to all sites, add an entry with a regex that always matches, e.g. /^.*$/.

Notes for iOS/iPadOS

Safari on iOS 15+ supports Userscripts via the built‑in script editor (Settings → Safari → Extensions).

After installing this script in the extension, it will run automatically on every page you visit.