Przeszukaj pomoc

Unikaj oszustw związanych z pomocą.Nigdy nie będziemy prosić Cię o dzwonienie na numer telefonu, wysyłanie SMS-ów ani o udostępnianie danych osobowych. Zgłoś podejrzaną aktywność, korzystając z opcji „Zgłoś nadużycie”.

Learn More

calling sidebarAction.open() from tabs.onActivated event

  • Nie ma odpowiedzi
  • 1 osoba ma ten problem
  • 8 wyświetleń
more options

I want wrote extension, that will open sidebar (with bookmarks) on New Tab, and close it on other tabs.

I make background script with next content: ``` browser.tabs.onActivated.addListener(function(tab){ if(tab.url=="about:newtab") browser.sidebarAction.open() else browser.sidebarAction.close() }) ``` And I get next error in console: `browser.sidebarAction is undefined`

Also I can see here that such actions "can only be called from inside the handler for a user action." Clicking the extension's browser action or page action.

And I want ensure whether tabs.onActivated event is a User action?

And if not, is there any ways or suggestions to go around this limitation?

I want wrote extension, that will open sidebar (with bookmarks) on New Tab, and close it on other tabs. I make background script with next content: ``` browser.tabs.onActivated.addListener(function(tab){ if(tab.url=="about:newtab") browser.sidebarAction.open() else browser.sidebarAction.close() }) ``` And I get next error in console: `browser.sidebarAction is undefined` Also I can see [https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/User_actions here] that such actions "can only be called from inside the handler for a user action." Clicking the extension's browser action or page action. And I want ensure whether tabs.onActivated event is a User action? And if not, is there any ways or suggestions to go around this limitation?