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