Reputation: 733
I'm trying to create a very basic chrome extension that changes a label on the screen to "hi", but it doesn't seem to be working.
This is my manifest.json:
{
"manifest_version" : 2,
"name": "My Extension",
"version": "1",
"description": "Testing",
"content_scripts": [
{
"matches": ["http://roblox.com/*"],
"js": ["jquery.min.js"]
}
],
"background": {
"scripts": ["jquery.min.js", "run.js"]
},
"permissions": [
"tabs",
"<all_urls>",
"contentSettings"
]
}
and this is the background script that is supposed to change the label
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
if (changeInfo.status === 'complete') {
chrome.tabs.executeScript(tabId, {
code: "$('.robux-amount').text('hi')"
});
}
});
Upvotes: 0
Views: 89
Reputation: 1001
It looks like your jquery.min.js is not getting included at the time of tabs update (on which you have attached a listener) Try this
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
if (changeInfo.status === 'complete') {
chrome.tabs.executeScript(tabId, { file: "jquery.min.js" }, function () {
chrome.tabs.executeScript(tabId, {
code: "$('.robux-amount').text('hi')"
});
}
});
});
Upvotes: 1