Tampermonkey® by Jan Biniok

GM_openInTab(url, options), GM_openInTab(url, loadInBackground)

GM_openInTab allows userscripts to open a new tab in the browser and navigate to a specified URL.

The function takes two parameters:

A string names "url" containing the URL of the page to open in the new tab.

An optional options object that can be used to customize the behavior of the new tab. The available options include:

  • active: A boolean value indicating whether the new tab should be active (selected) or not. The default is false.
  • insert: An integer indicating the position at which the new tab should be inserted in the tab strip. The default is false, which means the new tab will be added to the end of the tab strip.
  • setParent: A boolean value indicating whether the new tab should be considered a child of the current tab. The default is false.
  • incognito A boolean value that makes the tab being opened inside a incognito mode/private mode window.
  • loadInBackground A boolean value has the opposite meaning of active and was added to achieve Greasemonkey 3.x compatibility.

The function returns an object with the function close, the listener onclose and a flag called closed.

Here is an example of how the function might be used:

// Open a new tab and navigate to the specified URL
GM_openInTab("https://www.example.com/");