-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGM.cs
More file actions
236 lines (222 loc) · 9.54 KB
/
GM.cs
File metadata and controls
236 lines (222 loc) · 9.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
using CSharpToJavaScript.Utils;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CSharpToJavaScript.APIs.JS;
/// <summary>
/// <see href="https://wiki.greasespot.net/Greasemonkey_Manual:API">Greasemonkey API</see>
/// </summary>
[To(ToAttribute.Default)]
public partial class GM
{
/// <summary>
///
/// </summary>
public GM() { }
/// <summary>
/// This method deletes an existing name / value pair from storage.
/// See GM.setValue for details regarding the storage of these values.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.deleteValue"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="name">Property name to delete. See GM.setValue for details on what names are valid.</param>
[To(ToAttribute.FirstCharToLowerCase)]
public static void DeleteValue(string name)
{
}
/// <summary>
/// This method retrieves a value that was set with GM.setValue. See GM.setValue for details on the storage of these values.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.getValue"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="name">String The property name to get. See GM.setValue for details.</param>
/// <returns></returns>
[To(ToAttribute.FirstCharToLowerCase)]
public static Task<dynamic> GetValue(string name)
{
return new Task<dynamic>(() => { return 0; });
}
/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.setValue"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="name">String The unique (within this script) name for this value. Should be restricted to valid Javascript identifier characters.</param>
/// <param name="value">String, Integer or Boolean Any valid value of these types. Any other type may cause undefined behavior, including crashes.</param>
[To(ToAttribute.FirstCharToLowerCase)]
public static void SetValue(string name, dynamic value)
{
}
/// <summary>
/// This method retrieves an array of preference names that this script has stored. See GM.setValue for details on the storage of these values.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.listValues"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <returns></returns>
[To(ToAttribute.FirstCharToLowerCase)]
public static Task<List<dynamic>> ListValues()
{
return new Task<List<dynamic>>(() => { return new List<dynamic>(); });
}
/// <summary>
/// Given a defined @resource, this method returns it as a URL.
/// Compatibility: Greasemonkey 4.0+
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.getResourceUrl"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="resourceName">String The name provided when the @resource was defined, follow that link for valid naming restrictions.</param>
/// <returns>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). </returns>
[To(ToAttribute.FirstCharToLowerCase)]
public static Task<string> GetResourceUrl(string resourceName)
{
return new Task<string>(() => { return "string url"; });
}
/// <summary>
/// This method displays a notification to the user, using the underlying browser and operating system's notification mechanism.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.notification"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="text">String The main notification text.</param>
/// <param name="title">String Optional. The title of the notification. If not provided, the title will be "Greasemonkey".</param>
/// <param name="image">String Optional. The URL for an image to display in the dialog. If not provided, the Greasemonkey logo will be used.</param>
/// <param name="onclick">Function Optional. Callback, triggered when the notification window is clicked.</param>
[To(ToAttribute.FirstCharToLowerCase)]
public static void Notification(string text, string title = "", string image = "", Action? onclick = null)
{
}
/// <summary>
/// This method opens the specified URL in a new tab.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.openInTab"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="url">String The URL to navigate the new tab to.</param>
/// <param name="open_in_background">Boolean Optional: force tab to/to not open in a background tab. Default (unspecified) behavior honors Firefox configuration.</param>
[To(ToAttribute.FirstCharToLowerCase)]
public static void OpenInTab(string url, bool open_in_background = false)
{
}
/// <summary>
/// This method allows user scripts to add an item to the User Script Commands menu.
/// Compatibility: Greasemonkey 4.11+
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.registerMenuCommand"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="caption">String The caption to display on the menu item.</param>
/// <param name="commandFunc">Function The function to call when this menu item is selected by the user.</param>
/// <param name="accessKey"> String A single character that can be used to select command when the menu is open. It should be a letter in the caption.</param>
[To(ToAttribute.FirstCharToLowerCase)]
public static void RegisterMenuCommand(string caption, Action commandFunc, string accessKey)
{
}
/// <summary>
/// Sets the current contents of the operating system's clipboard.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.setClipboard"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="text">String Any text.</param>
[To(ToAttribute.FirstCharToLowerCase)]
public static void SetClipboard(string text)
{
}
//TODO!
/// <summary>
/// This method performs a similar function to the standard XMLHttpRequest object, but allows these requests to cross the same origin policy boundaries.
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.xmlHttpRequest"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
/// <param name="details"></param>
[To(ToAttribute.FirstCharToLowerCase)]
public static void XmlHttpRequest(object details)
{
}
/// <summary>
/// An object that exposes various information about Greasemonkey and the running User Script.
/// Compatibility: Greasemonkey 0.9.16+
/// </summary>
/// <remarks>
/// <para><seealso href="https://wiki.greasespot.net/GM.info"> <em> See also on Greasemonkey Wiki</em> </seealso></para>
/// </remarks>
[To(ToAttribute.FirstCharToLowerCase)]
public static class Info
{
/// <summary>
/// An object containing data about the currently running script. See more detail below.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static class Script
{
/// <summary>
/// Possibly empty string.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string Description { get; set; } = string.Empty;
/// <summary>
/// Possibly empty array of strings.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string[] Excludes { get; set; } = [];
/// <summary>
/// Possibly empty array of strings.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string[] Includes { get; set; } = [];
/// <summary>
/// Possibly empty array of strings.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string[] Matches { get; set; } = [];
/// <summary>
/// String.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string Name { get; set; } = string.Empty;
/// <summary>
/// Possibly empty string.
/// </summary>
[Value("namespace")]
public static string Namespace_ { get; set; } = string.Empty;
//TODO!
/// <summary>
/// An object keyed by resource name. Each value is an object with keys name and mimetype and url with string values.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static object? Resources { get; set; } = null;
/// <summary>
/// String.
/// </summary>
[Value("run-at")]
public static string RunAt { get; set; } = string.Empty;
/// <summary>
/// Possibly empty string.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string Version { get; set; } = string.Empty;
}
/// <summary>
/// A string, the entire literal Metadata Block (without the delimiters) for the currently running script.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string ScriptMetaStr { get; set; } = string.Empty;
/// <summary>
/// The name of the user script engine handling this script's execution. The string Greasemonkey.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string ScriptHandler { get; set; } = string.Empty;
/// <summary>
/// The version of Greasemonkey, a string e.g. 4.0.
/// </summary>
[To(ToAttribute.FirstCharToLowerCase)]
public static string Version { get; set; } = string.Empty;
}
}