为何通过style属性无法覆盖User Agent样式表规则?
Ublock Origin注入的User Agent样式表无法被行内style覆盖的问题
我正在使用Ublock Origin浏览器扩展,它会向User Agent样式表注入以下CSS规则来隐藏广告:
a[href^="https://ad.doubleclick.net/"] { display: none !important; }
即使给目标链接添加了行内style属性,该链接仍会被隐藏:
there should be a link: <a href="https://ad.doubleclick.net/" style="display: block !important">example1</a>
尽管开发者工具显示行内style属性的优先级应该覆盖上述规则,但计算样式结果却显示链接依旧处于隐藏状态。而如果是用户样式表中的类似CSS规则,却可以被行内style属性正常覆盖:
用户样式表规则:
a[href^="https://example.net/"] { display: none !important; }
对应的HTML代码:
there should be a link: <a href="https://example.net/" style="display: block !important">example2</a>
请问这是浏览器Bug吗?有没有解决方法?
环境:Edge 119.0.2151.44,Windows 10 x64
内容的提问来源于stack exchange,提问作者vanowm
相关产品推荐
相关产品推荐

