【问题标题】:This extension doesn't work for me?这个扩展对我不起作用?
【发布时间】:2015-08-05 19:21:46
【问题描述】:

这是在我的 manifest.json 中:

{
  "manifest_version": 2,

  "name": "ROBLOX Forum Link Fixer",
  "description": "Fixes the amp; issue on the ROBLOX forum.",
  "version": "2.0",

  "background": {
    "scripts": [
      "jquery.js",
      "fixer.js"
    ]
  },
  "permissions": [
    "http://*.roblox.com/*",
    "https://*.roblox.com/*"
  ]
}

这是在 fixer.js 内部(jquery.js 只是 jQuery):

$(document).ready(function(){
    $('.rbx-link.user-link').each(function(){
        $(this).text($(this).text().replace(/amp;/g, ""));
        $(this).attr("href",$(this).text());
    });
});

错误是它不起作用,我不知道为什么?!我希望有人能帮帮忙!谢谢。

【问题讨论】:

  • 内容脚本,而不是后台脚本。
  • @dsg 所以只是将背景更改为内容?我还不擅长这个 google chrome 扩展的东西。这是我的第一个。
  • 请花点时间阅读Architecture Overview

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


【解决方案1】:

我认为您必须使用内容脚本权限,例如

"content_scripts": [
    {
      "matches": ["http://www.google.co.in/*",
       "https://www.google.co.in/*"],
      "js": ["myscript.js"]
    }
  ]
}

而不是背景见 https://developer.chrome.com/extensions/content_scripts

【讨论】:

    猜你喜欢
    • 2012-07-13
    • 2017-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 2012-01-15
    • 1970-01-01
    相关资源
    最近更新 更多