2

有没有办法使用 Stylish 排除网站的子文件夹?

@-moz-document domain("www.website.com") { }

将影响 website.com 的所有页面。问题是,这个网站还托管了www.website.com/wiki/*一个风格完全不同的 wiki ( )。
一些时尚的 CSS 也会影响这个 wiki,我想避免这种情况。

有没有办法做到这一点?我读过:在 Firefox 的某些网站上禁用时尚,但这是针对全球风格的,我没有。

我应该说我对正则表达式一无所知。

4

1 回答 1

3

我对 Stylish 编码一无所知,但假设您可以使用 RegEx,您可以尝试以下方法:

www.website.com(?!\/wiki\/).*

所以你的完整代码将是:

@-moz-document regexp('https?://www\\.website\\.com(?!/wiki/).*') {
  ...
}

以下是 RegEx 的工作方式:

http          # Selects HTTP protocol
s?            # Options s for HTTPS protocol
://           # :// After Protocol
www           # www
\\.           # Escaped . (dot)
website\\.com # Website
(?!           # Start of negative lookahead, If anything inside is found, the match will fail
    /wiki/        # Don't match if inside /wiki/ directory
)             # End of negative lookahead
.*            # Selects any character (.) any amount of times (*)

Live Demo on RegExr

于 2016-03-20T17:06:09.157 回答