简体   繁体   English

Chrome扩展程序无法首次使用

[英]Chrome extension doesn't work first time

I have a chrome extension that adds a custom button beside the "like" button in facebook. 我有一个chrome扩展,在facebook的“喜欢”按钮旁边添加了一个自定义按钮。

The problem is that when I launch facebook that button doesn't appear and when I refresh the page it appears. 问题是,当我启动Facebook时,没有出现按钮,当我刷新页面时,它会出现。

It's a basic jQuery script: 这是一个基本的jQuery脚本:

$(".like_link").after("...MY BUTTON...");

I also tried to put an alert("extension works") function to see when the extension is loaded and when it doesn't. 我还尝试设置一个警报(“扩展工程”)功能,以查看何时加载扩展程序以及何时加载扩展程序。 So the problem is not of the button, it's a problem of the extension itself. 所以问题不在于按钮,这是扩展本身的问题。

I tried one more thing, I set the extension to work on all the websites ( *://*.* in manifest.json). 我尝试了另外一件事,我将扩展设置为在所有网站上工作(manifest.json中的*://*.* )。 In all the websites it worked all the time, and in facebook I had to refresh every page after I launched it. 在所有的网站上,它一直都在工作,在facebook中,我必须在我启动它之后刷新每一页。

jQuery id LOADED into my extension. jQuery id加载到我的扩展中。 My manifest.json file: 我的manifest.json文件:

{
"name": "Custom button",
"version": "0.1",
"description": "Add a custom button beside the like button!",
"content_scripts": [
    {
    "matches": ["*://facebook.com/*"], //or *://*/*
    "css": ["style.css"],
    "js": ["jquery-1.7.2.min.js","script.js"]
    }
]
}

"matches": ["*://*.facebook.com/*"]怎么样"matches": ["*://*.facebook.com/*"] (在facebook.com之前插入星号)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM