Table of Contents

Class GM

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
[To("Default")]
public class GM
Inheritance
GM
Inherited Members

Constructors

GM()

public GM()

Methods

DeleteValue(string)

This method deletes an existing name / value pair from storage. See GM.setValue for details regarding the storage of these values.

[To("FirstCharToLowerCase")]
public static void DeleteValue(string name)

Parameters

name string

Property name to delete. See GM.setValue for details on what names are valid.

Remarks

GetResourceUrl(string)

Given a defined @resource, this method returns it as a URL. Compatibility: Greasemonkey 4.0+

[To("FirstCharToLowerCase")]
public static Task<string> GetResourceUrl(string resourceName)

Parameters

resourceName string

String The name provided when the @resource was defined, follow that link for valid naming restrictions.

Returns

Task<string>

A Promise, rejected on failure and resolved with a String URL on success. Treat the result as opaque string. It will work where you need a URL (for a link or style for CSS, for and img tag, or similar).

Remarks

GetValue(string)

This method retrieves a value that was set with GM.setValue. See GM.setValue for details on the storage of these values.

[To("FirstCharToLowerCase")]
public static Task<dynamic> GetValue(string name)

Parameters

name string

String The property name to get. See GM.setValue for details.

Returns

Task<dynamic>

Remarks

ListValues()

This method retrieves an array of preference names that this script has stored. See GM.setValue for details on the storage of these values.

[To("FirstCharToLowerCase")]
public static Task<List<dynamic>> ListValues()

Returns

Task<List<dynamic>>

Remarks

Notification(string, string, string, Action?)

This method displays a notification to the user, using the underlying browser and operating system's notification mechanism.

[To("FirstCharToLowerCase")]
public static void Notification(string text, string title = "", string image = "", Action? onclick = null)

Parameters

text string

String The main notification text.

title string

String Optional. The title of the notification. If not provided, the title will be "Greasemonkey".

image string

String Optional. The URL for an image to display in the dialog. If not provided, the Greasemonkey logo will be used.

onclick Action

Function Optional. Callback, triggered when the notification window is clicked.

Remarks

OpenInTab(string, bool)

This method opens the specified URL in a new tab.

[To("FirstCharToLowerCase")]
public static void OpenInTab(string url, bool open_in_background = false)

Parameters

url string

String The URL to navigate the new tab to.

open_in_background bool

Boolean Optional: force tab to/to not open in a background tab. Default (unspecified) behavior honors Firefox configuration.

Remarks

RegisterMenuCommand(string, Action, string)

This method allows user scripts to add an item to the User Script Commands menu. Compatibility: Greasemonkey 4.11+

[To("FirstCharToLowerCase")]
public static void RegisterMenuCommand(string caption, Action commandFunc, string accessKey)

Parameters

caption string

String The caption to display on the menu item.

commandFunc Action

Function The function to call when this menu item is selected by the user.

accessKey string

String A single character that can be used to select command when the menu is open. It should be a letter in the caption.

Remarks

SetClipboard(string)

Sets the current contents of the operating system's clipboard.

[To("FirstCharToLowerCase")]
public static void SetClipboard(string text)

Parameters

text string

String Any text.

Remarks

SetValue(string, dynamic)

This method allows user script authors to persist simple values across page loads and across origins. Strings, booleans, and integers are currently the only allowed data types.

[To("FirstCharToLowerCase")]
public static void SetValue(string name, dynamic value)

Parameters

name string

String The unique (within this script) name for this value. Should be restricted to valid Javascript identifier characters.

value dynamic

String, Integer or Boolean Any valid value of these types. Any other type may cause undefined behavior, including crashes.

Remarks

XmlHttpRequest(object)

This method performs a similar function to the standard XMLHttpRequest object, but allows these requests to cross the same origin policy boundaries.

[To("FirstCharToLowerCase")]
public static void XmlHttpRequest(object details)

Parameters

details object

Remarks