You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome扩展manifest.json中Google链接末尾/*为何在搜索页不生效?

解决Chrome扩展仅Google首页生效、搜索页不生效的问题

你的manifest.json里的matches规则https://www.google.com/*其实是可以匹配搜索页的,问题出在CSS优先级被Google搜索页的内置样式覆盖了。可以通过以下两步解决:

一、提升CSS样式优先级

修改main.css,使用更具体的选择器并强制覆盖原样式:

/* 匹配Google搜索页的body元素 */
body#gsr, body.srp {
    background: url(https://wallpaperaccess.com/full/1554103.jpg) !important;
    background-size: cover !important; /* 确保背景图铺满页面 */
    background-position: center center !important; /* 居中显示背景图 */
}

/* 同时保留对首页的支持 */
html body {
    background: url(https://wallpaperaccess.com/full/1554103.jpg) !important;
}

Google搜索页的body会带有gsr id或srp类名,用这些更具体的选择器能提升优先级,!important则强制覆盖页面原有背景样式。

二、优化matches规则(可选)

如果需要支持不同地区的Google域名(比如google.co.uk、google.de)或者非www的域名,将manifest.json里的matches改为:

"matches": ["https://*.google.com/*"]

通配符*.google.com会匹配所有Google的子域名,确保扩展在更多Google页面生效。

内容的提问来源于stack exchange,提问作者Stephan Teig

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 14:45:38