Go back to top

vivaldi.tabsPrivate Modders API Reference

Use the vivaldi.tabsPrivate API to update tabs

Types

#TabAlertState

ENUM

The active media type.

  • recording
  • capturing
  • playing
  • muting
  • bluetooth
  • usb
  • pip
  • desktop_capturing
  • vr_presenting_in_headset
  • serial_connected
  • #TranslateStep

    ENUM

    Denotes which state the page is in with respect to translate.

  • idle
  • before_translate
  • translating
  • after_translate
  • translate_error
  • #TranslateError

    ENUM

    Signals translation errors.

  • no_error
  • network
  • init_error
  • unknown_language
  • unsupported_language
  • identical_languages
  • translation_error
  • translation_timeout
  • unexpected_script_error
  • bad_origin
  • script_load_error
  • #UpdateTabInfo

    Object passed to the update and returned in the get function function.

    Properties:

    showImages
    (optional)
    boolean

    Show images for all pages loaded in this tab. Default is true.

    loadFromCacheOnly
    (optional)
    boolean

    Only load the page from cache. Default is false.

    mimeType
    (optional)
    string

    The current documents mimetype.

    muteTab
    (optional)
    boolean

    If the tab should be quiet.

    #DragData

    Provides custom drag data.

    Properties:

    windowId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    mimeType
    string

    The mime type to use for the custom data.

    customData
    string

    The custom data.

    url
    string

    The url for the data. Needed for the html5 drag and drop engine. Not set in the onDropEnd event.

    title
    string

    The title for the data. Needed for the html5 drag and drop engine. Not set in the onDropEnd event.

    imageData
    (optional)
    binary

    The raw image data in RGBA format for the image to use during drag drop instead of a tab capture.

    posX
    (optional)
    number

    X offset inside the given app window in the UI coordinates.

    posY
    (optional)
    number

    Y offset inside the given app window in the UI coordinates.

    width
    number

    Width of the capture in the UI coordinates.

    height
    number

    Height of the capture in the UI coordinates.

    cursorX
    integer

    X offset into the image for the cursor during drag.

    cursorY
    integer

    Y offset into the image for the cursor during drag.

    isFromTouch
    (optional)
    boolean

    True if the drag was initiated from touch. Default is false.

    Rect struct for spatial navigation.

    Properties:

    left
    integer

    left

    top
    integer

    top

    width
    integer

    width

    height
    integer

    height

    right
    integer

    right

    bottom
    integer

    bottom

    href
    string

    Url of focused element in case it's a link.

    ENUM

    Which direction to move the current spatnav rect.

  • left
  • right
  • up
  • down
  • #LanguageDetectionDetails

    Details the language detection for the current page. Corresponds to LanguageDetectionDetails in C++.

    Properties:

    url
    string

    The url of the page detected was done on.

    contentLanguage
    string

    The language detected by the content (Content-Language).

    cldLanguage
    string

    The language detected by CLD (Chromium's Compact Language Detector library).

    isCldReliable
    boolean

    true if the CLD detection is reliable, otherwise false.

    hasNoTranslate
    boolean

    Whether the notranslate is specified in head tag as a meta; or

    htmlRootLanguage
    string

    The language written in the lang attribute of the html element.

    adoptedLanguage
    string

    The adopted language, usually a authoritive decision on the different language tags in a document.

    #CloseSpatnavParams

    Reports layout change and element null check

    Properties:

    layout_changed
    boolean

    True if layout changed

    current_element_valid
    boolean

    True is current element is not null. Currently used to see if previous escape closed a menu that made our current element disappear.

    Listeners

    How to use listeners

    Each listener type has the same functions, used for each listener API in the same way:

    .addListener(function callback)

    Adds a function to a listener for an event

    .removeListener(function callback)

    Removes a function to a listener for an event

    .hasListener(function callback)

    Returns a boolean if a function is attached to a listener for an event

    .hasListeners()

    Returns a boolean if a listener has any attached functions

    .dispatch()

    Returns array of promises dispatched to the listener

    #onMediaStateChanged

    Fired when the media state changes on the tab.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    windowId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    tabState

    All the active media states for this tab.

    Array of:

    • TabAlertState

    #onThemeColorChanged

    Fired when a meta theme-color has a value from the web page.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    rgb
    string

    Fired when the theme-color in the meta header field has changed. Format is #rrggbb and provided in css hex.

    #onTabUpdated

    Fires when a |WebContent| is changed in some way.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    windowId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    tabInfo
    UpdateTabInfo

    ⚠ NO DESCRIPTION PROVIDED

    #onDragEnd

    Fires when tab dragging ends.

    Parameters:

    dragAborted
    boolean

    This is an aborted drag (using ESC or similar).

    dropOutsideWindow
    boolean

    This is a valid drop outside any app window.

    posX
    integer

    X position of the drop in screen coordinates.

    posY
    integer

    Y position of the drop in screen coordinates.

    #onPermissionAccessed

    Fires when a |permission| is accessed.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    permission
    string

    ⚠ NO DESCRIPTION PROVIDED

    origin
    string

    ⚠ NO DESCRIPTION PROVIDED

    blocked
    string

    Current permission setting. 'allow', 'block', 'ask' or 'default'

    #onKeyboardChanged

    Fires for all keyboard changes that have not been consumed by the browser

    Parameters:

    windowId
    integer

    Id of the browser window this keyboard event originates from.

    down
    boolean

    True when pressed, false when released

    modifiers
    integer

    Modifier state when change occured

    windowsKeyCode
    integer

    Value of key that changed

    afterGesture
    boolean

    True when the keyboard event completed a mouse or wheel gesture

    autoRepeat
    boolean

    True if the event is a result of automatic keyboard repeat.

    #onMouseChanged

    Fires when mouse state has changed.

    Parameters:

    motion
    boolean

    True when mouse has moved, false when mouse is pressed/released.

    #onKeyboardShortcut

    Fires when on a keystroke that hasn't been consumed by the browser

    Parameters:

    windowId
    integer

    Id of the browser window this keyboard event originates from.

    shortcutText
    string

    String representation of a keyboard shortcut

    autoRepeat
    boolean

    True if the shortcut is generated as a result of automatic keyboard repeat

    fromDevtools
    boolean

    True if the shortcut comes from a devtools window

    #onTabIsDetached

    Fired when a tab that is moved out of a window detaches from the source-window. This is used to make sure two WebViews don't try to use the same WebContents.

    Parameters:

    tabId
    integer

    Tab id used for Tabstrip WebContents retrieval.

    windowId
    integer

    Target WindowId that the message is intended. As in not the window it is detached from, but the window it is attached to.

    #onTabIsAttached

    Fired when a WebContents is attached to an embedder. This is used to make sure two WebViews don't try to use the same WebContents.

    Parameters:

    tabId
    integer

    Tab id used for Tabstrip WebContents retrieval.

    windowId
    integer

    WindowId of the embedder.

    #onMouseGestureDetection

    Fires when we detect a possible start of a mouse-gesture related event

    Parameters:

    windowId
    integer

    Id of the Vivaldi window where the event was originated

    #onMouseGesture

    Fires when the user triggered a mouse gesture

    Parameters:

    windowId
    integer

    Id of the Vivaldi window where the event was originated

    clientX
    number

    X-coordinate of the gesture start point

    clientY
    number

    Y-coordinate of the gesture start point

    gestureDirections
    string

    Sequence of gesture directions

    #onTabSwitchEnd

    Fires when the tab switch using mouse wheel terminates

    Parameters:

    windowId
    integer

    Id of the Vivaldi window where the event was originated

    #onRockerGesture

    Fires when the user triggered a rocker gesture

    Parameters:

    windowId
    integer

    Id of the Vivaldi window where the event was originated

    isLeft
    boolean

    True if this is the left rocker gesture

    #onWebviewClickCheck

    Fires to check if the user clicks on a webview.

    Parameters:

    windowId
    integer

    Id of the Vivaldi window where the event was originated

    mousedown
    boolean

    true if this is a mousedown event, false for mouseup

    button
    integer

    the mouse button that was pressed, the values match DOM's MouseEvent.button

    clientX
    number

    X-coordinates of the click

    clientY
    number

    Y-coordinates of the click

    #onPageZoom

    Fires on page zoom events

    Parameters:

    windowId
    integer

    Id of the Vivaldi window where the event was originated

    steps
    number

    Number of basic steps to increase or decrease zoom.

    clientX
    number

    X-coordinates of the pointer position

    clientY
    number

    Y-coordinates of the pointer position

    #onBeforeUnloadDialogClosed

    Fired when a beforeunload dialog has been closed.

    Parameters:

    windowId
    integer

    Window Id containg the tab Id.

    tabId
    integer

    Tab id for the beforeunload dialog.

    proceed
    boolean

    If true, the tab operation that triggered the dialog has been allowed to proceed.

    #onLanguageDetermined

    Fired when the language of the current page has been determined.

    Parameters:

    tabId
    integer

    The tab Id.

    details
    LanguageDetectionDetails

    ⚠ NO DESCRIPTION PROVIDED

    #onShowTranslationUI

    Fired when we should show translation UI. The status decides what UI we should show.

    Parameters:

    tabId
    integer

    The tab Id.

    step
    TranslateStep

    ⚠ NO DESCRIPTION PROVIDED

    error
    TranslateError

    ⚠ NO DESCRIPTION PROVIDED

    automaticTranslation
    boolean

    true if this was triggered by an automatic translation.

    #onPageTranslated

    Fired when a translation has been completed on a page.

    Parameters:

    tabId
    integer

    The tab Id.

    srcLang
    string

    Source language code it was translated from.

    destLang
    string

    Destination language code it was translated to.

    error
    TranslateError

    ⚠ NO DESCRIPTION PROVIDED

    #onIsPageTranslatedChanged

    Fired when a translation state has changed on a page, eg. revert has been used.

    Parameters:

    tabId
    integer

    The tab Id.

    isTranslated
    boolean

    The translation state has changed. For eg. revert, it will be false after revert has been invoked.

    Methods

    #update

    Update the given tab with Vivaldi-specific properties.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    tabInfo
    UpdateTabInfo

    ⚠ NO DESCRIPTION PROVIDED

    #get

    Get Vivaldi-specific properties from the tab.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    #insertText

    Insert text into editable fields.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    text
    string

    The text to insert

    #startDrag

    Starts the HTML5 drag of the given tabs.

    Parameters:

    dragData
    DragData

    The drag data to be transported in the dataobject.

    #scrollPage

    Scrolls the page up or down, depending on a parameter

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    scrollType
    string

    Whether to scroll up or down, and by how much

    scrollAmount
    (optional)
    integer

    The amount to scroll by

    #moveSpatnavRect

    Move current spatnav rect in |direction|

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    direction
    NavigationDirection

    ⚠ NO DESCRIPTION PROVIDED

    #activateSpatnavElement

    Activate currently focused spatnav element

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    modifiers
    integer

    Keyboard modifiers to simulate shift or ctrl-clicking

    #closeSpatnavOrCurrentOpenMenu

    Returns true if layout changes by un-hovering the current spatnav element.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    #hasBeforeUnloadOrUnload

    Check if a page contains a beforeunload or unload handler.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    #translatePage

    Attempts to translate the given page.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    srcLang
    string

    Source language code to translate from. May be omitted.

    destLang
    string

    Destination language code to translate to. Must be present.

    #revertTranslatePage

    Attempts to revert the translating of the given page.

    Parameters:

    tabId
    integer

    ⚠ NO DESCRIPTION PROVIDED

    #determineTextLanguage

    Attempts to determined the language of the given text.

    Parameters:

    tabId
    integer

    Any valid tabId can be used here, it is only used to determine which renderer to use.

    text
    string

    String to determine the language for. If the string is too short, this operation might not yield a language code.