I'm trying to make an extension that reloads a tab every 2 minutes, but I want it to try and reload even if the internet was offline (so it would reload when it went back on). Using location.reload() doesn't work when the window gives an error (e.g. offline), so I figured the best way was using chrome.tabs.reload().
The problem is, all chrome.tabs give me a similar error, if I try with an empty argument it should work, since it defaults to the current tab according to the documentation, but instead:
chrome.tabs.reload({});
Uncaught TypeError: Cannot call method 'reload' of undefined
If I try to get the current tab ID:
chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
console.log(tabs[0]);
});
Uncaught TypeError: Cannot call method 'query' of undefined
And similarly, every single chrome.tabs
has a similar error, "Cannot call xxyyzz of undefined". It's as if chrome couldn't see my tabs, what's going on?
My manifest.js is:
{
"manifest_version": 2,
"name": "test",
"description": "",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"js": ["reload.js"],
"run_at": "document_end"
}
],
"permissions": [
"tabs","storage","http://www.google.com"
]
}