简体   繁体   中英

Chrome extension doesn't work first time

I have a chrome extension that adds a custom button beside the "like" button in facebook.

The problem is that when I launch facebook that button doesn't appear and when I refresh the page it appears.

It's a basic jQuery script:

$(".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). In all the websites it worked all the time, and in facebook I had to refresh every page after I launched it.

jQuery id LOADED into my extension. My manifest.json file:

{
"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之前插入星号)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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