CSS injection fails using declaration in content_scripts, but works when loaded via injected JavaScript

前端 未结 1 1075
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 18:49

I\'ve noted that the expected way of injecting CSS into a third-party page does not seem to be working appropriately.

Relevant manifest.json portions:

           


        
相关标签:
1条回答
  • 2021-01-27 18:55

    It appears that Chrome ignores the query string and location fragment when it checks whether the CSS file declared in the manifest file has to be applied.

    http://www.youtube.com/watch?v=VIDEOID is seen as
    http://www.youtube.com/watch.

    Your match pattern includes a part of the query string, which causes the pattern to not match at all.

    Currently, the behaviour of "matches" is inconsistent:

    Documentation
        Pattern     : https://*.google.com/foo*bar
        What it does: Matches (...) path starts with /foo and ends with bar
    "js" in manifest file
        Checks if pattern matches scheme://host/path?querystring
        Example     : https://google.com/foo?bar
        Non-example : https://google.com/foobar?
    "css" in manifest file
        Checks if pattern matches scheme://host/path
        Example     : https://google.com/foobar?thisisignored
        Non-example : https://google.com/foo?bar
    In all cases, the location fragment (aka location hash) is ignored.
    

    This bug has been reported over 2 years ago, but it didn't catch up:

    • Issue 68561: Manifest content_scripts 'matches' inconsistently applied

    There's another bug, possibly related, which has more followers:

    • Issue 100106: Excluding domains from content scripts doesn't work for CSS files
    0 讨论(0)
提交回复
热议问题