From GreaseSpot Wiki
Revision as of 02:38, 24 August 2021 by Gholk (talk | contribs) (add sample class to code block)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


Calling window.focus() will make browser switch the tab of User script, without registration of service worker. This API does not require @grant in metadata block.

Calling this function in normal JavaScript context in invalid because the permission to focus a window require a service worker. See WindowClient.focus.


GM.notification("you can switch to the tab", "focus", '', () => {
  alert("you are in the tab now");