I am trying to reload a page that a user may have open in one of their tabs from popup (specifically popup.js). I am looking at this answer but it is only for the current tab https://stackoverflow.com/a/25246060/8786209.
Also when it runs I get this error:
popup.html:1 Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "thewebpageiamtryingtoaccess.com".
Extension manifest must request permission to access this host at Object.callback (chrome-extension://mjckbfpnokoplldjpijdfhffbbbfflah/popup.js:3:17)
I have added
"permissions": [
"tabs"
],
inside my manifest, still no luck. How would I be able to do it for a specific tab that the user has open. I want this to reload the website the first time the extension is loaded so the the user does not have to reload the webpage manually to have the content script take effect. Thanks!
It is very easy and super simple - just set the time interval that you want to auto refresh your pages or tabs and the Page-refresh extension will auto reload the pages.
Bring back a tab or window If you accidentally close a tab or window, you can open it again using a keyboard shortcut: Windows & Linux: Ctrl + Shift + t. Mac: ⌘ + Shift + t.
Tab Auto Refresh is a browser addon that helps you automatically reload (refresh) tabs of your choice. To operate with this addon, please open toolbar popup UI while you are visiting a website. Adjust time interval in seconds (i.e. 120 sec) and you are all set.
For fixing execute error you need to change permissions in your manifest file to:
"permissions": [
"tabs",
"http://*/",
"https://*/"
]
You can query ID of the tab by url like this:
chrome.tabs.query({url: "http://thewebpageiamtryingtoaccess.com/*"}, function(tab) {
// reload tab with one of the methods from linked answer
chrome.tabs.reload(tab[0].id)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With