Skip to content

Latest commit

 

History

History
84 lines (47 loc) · 1.55 KB

userScripts.rst

File metadata and controls

84 lines (47 loc) · 1.55 KB

≡ userScripts API

userScripts API

.. rst-class:: api-permission-info

Note

A manifest entry named user_scripts is required to use messenger.userScripts.*.

.. rst-class:: api-main-section

Events

onBeforeScript

.. api-section-annotation-hack::

Event called when a new userScript global has been created

.. api-header::
   :label: Parameters for onBeforeScript.addListener(listener)


   .. api-member::
      :name: ``listener(userScript)``

      A function that will be called when this event occurs.


.. api-header::
   :label: Parameters passed to the listener function


   .. api-member::
      :name: ``userScript``
      :type: (object)

      .. api-member::
         :name: ``defineGlobals``
         :type: (function)

         Exports all the properties of a given plain object as userScript globals


      .. api-member::
         :name: ``export``
         :type: (function)

         Convert a given value to make it accessible to the userScript code


      .. api-member::
         :name: ``global``
         :type: (any)

         The userScript global


      .. api-member::
         :name: ``metadata``
         :type: (any)

         The userScript metadata (as set in userScripts.register)