【问题标题】:Insert CSS in Chrome Extension在 Chrome 扩展中插入 CSS
【发布时间】:2012-07-02 07:16:19
【问题描述】:

我知道可以使用 Content_Scripts 将 CSS 添加到页面,但我想在 JS 文件中使用 InsertCSS 函数。

我有:

chrome.tabs.insertCSS(null, {code: "adfree.css"});

但它不会改变网页的任何内容。我给了权限:

"permissions": [
    "tabs", "*://*"
],

为什么它不起作用?

编辑:

chrome.tabs.insertCSS({file: "adfree.css"});

chrome.tabs.insertCSS(null, {file: "adfree.css"});

也不行……

【问题讨论】:

  • 我也有同样的问题。可能是文件路径有问题。

标签: javascript json google-chrome google-chrome-extension


【解决方案1】:

您正在向它传递一个文件名,但使用 code 键,而您应该使用 file 键:

chrome.tabs.insertCSS(null, {file: "adfree.css"});

请参阅the documentation 了解更多信息。

【讨论】:

  • 试过了,还有 chrome.tabs.insertCSS({file: "adfree.css"});,但没有用
猜你喜欢
  • 2013-11-15
  • 1970-01-01
  • 1970-01-01
  • 2012-02-25
  • 2013-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多