Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using Microsoft.Win32;
  8. using System.IO;
  9. using System.Net;
  10. namespace MonacoAPI
  11. {
  12. public class MonacoFuncs
  13. {
  14. public void SetText(WebBrowser monaco, String text) // monaco as chosen webbrowser and text as which string you want to get text from
  15. {
  16. monaco.Document.InvokeScript("SetText", new object[]
  17. {
  18. text
  19. });
  20. }
  21. public String MonacoText;
  22. public void GetTextFunc(WebBrowser monaco) // monaco as webbrowser name (get text from) and text as the object you want to set text to
  23. {
  24. try
  25. {
  26. HtmlDocument document = monaco.Document;
  27. string scriptName = "GetText";
  28. object[] args = new string[0];
  29. object obj = document.InvokeScript(scriptName, args);
  30. string script = obj.ToString();
  31. MonacoText = script;
  32. }
  33. catch(Exception)
  34. {
  35. MessageBox.Show("Exception: Invalid WebBrowser / use string 'MonacoText' to assign values (object.text = MonacoText)");
  36. }
  37. }
  38.  
  39. private string defPath = Application.StartupPath + "//Monaco//";
  40. WebBrowser monacobrowser = new WebBrowser();
  41. private void AddIntel(string label, string kind, string detail, string insertText)
  42. {
  43. string text = "\"" + label + "\"";
  44. string text2 = "\"" + kind + "\"";
  45. string text3 = "\"" + detail + "\"";
  46. string text4 = "\"" + insertText + "\"";
  47. monacobrowser.Document.InvokeScript("AddIntellisense", new object[]
  48. {
  49. label,
  50. kind,
  51. detail,
  52. insertText
  53. });
  54. }
  55.  
  56. private void addGlobalF()
  57. {
  58. string[] array = File.ReadAllLines(this.defPath + "//globalf.txt");
  59. foreach (string text in array)
  60. {
  61. bool flag = text.Contains(':');
  62. if (flag)
  63. {
  64. this.AddIntel(text, "Function", text, text.Substring(1));
  65. }
  66. else
  67. {
  68. this.AddIntel(text, "Function", text, text);
  69. }
  70. }
  71. }
  72.  
  73. private void addGlobalV()
  74. {
  75. foreach (string text in File.ReadLines(this.defPath + "//globalv.txt"))
  76. {
  77. this.AddIntel(text, "Variable", text, text);
  78. }
  79. }
  80.  
  81. private void addGlobalNS()
  82. {
  83. foreach (string text in File.ReadLines(this.defPath + "//globalns.txt"))
  84. {
  85. this.AddIntel(text, "Class", text, text);
  86. }
  87. }
  88.  
  89. private void addMath()
  90. {
  91. foreach (string text in File.ReadLines(this.defPath + "//classfunc.txt"))
  92. {
  93. this.AddIntel(text, "Method", text, text);
  94. }
  95. }
  96.  
  97. private void addBase()
  98. {
  99. foreach (string text in File.ReadLines(this.defPath + "//base.txt"))
  100. {
  101. this.AddIntel(text, "Keyword", text, text);
  102. }
  103. }
  104.  
  105. public void Initialize(WebBrowser monaco)
  106. {
  107. if (Directory.Exists(Directory.GetCurrentDirectory() + "\\Monaco\\"))
  108. {
  109. monacobrowser = monaco;
  110. WebClient wc = new WebClient();
  111. wc.Proxy = null;
  112. try
  113. {
  114.  
  115. RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
  116. string friendlyName = AppDomain.CurrentDomain.FriendlyName;
  117. bool flag2 = registryKey.GetValue(friendlyName) == null;
  118. if (flag2)
  119. {
  120. registryKey.SetValue(friendlyName, 11001, RegistryValueKind.DWord);
  121. }
  122. registryKey = null;
  123. friendlyName = null;
  124. }
  125. catch (Exception)
  126. {
  127. }
  128. monaco.Url = new Uri(string.Format("file:///{0}/Monaco/Monaco.html", Directory.GetCurrentDirectory()));
  129. Task.Delay(500);
  130. monaco.Document.InvokeScript("SetTheme", new string[]
  131. {
  132. "Light"
  133. });
  134. }
  135. else
  136. {
  137. MessageBox.Show("Exception: couldnt find directory 'Monaco'");
  138. }
  139. }
  140.  
  141. public async void SetTheme(WebBrowser monaco, string text)
  142. {
  143. try
  144. {
  145. await Task.Delay(500);
  146. monaco.Document.InvokeScript("SetTheme", new string[]
  147. {
  148. text
  149.  
  150. });
  151. }
  152. catch (Exception)
  153. {
  154. MessageBox.Show("Exception: only 2 themes available, 'Light' and 'Dark', or string entry point was unavailable. if the fixes still doesnt work, proceed to use 'SetThemeIfException'");
  155. }
  156. }
  157.  
  158. public async Task SetThemeIfException(WebBrowser monaco, string theme)
  159. {
  160. await Task.Delay(500);
  161. monaco.Document.InvokeScript("SetTheme", new string[]
  162. {
  163. theme
  164.  
  165. });
  166. }
  167.  
  168. public void addIntel(string label, string kind, string detail, string insertText)
  169. {
  170. string text = "\"" + label + "\"";
  171. string text2 = "\"" + kind + "\"";
  172. string text3 = "\"" + detail + "\"";
  173. string text4 = "\"" + insertText + "\"";
  174. monacobrowser.Document.InvokeScript("AddIntellisense", new object[]
  175. {
  176. label,
  177. kind,
  178. detail,
  179. insertText
  180. });
  181. }
  182. public void ReplaceText(WebBrowser monaco, String firstarray, String secondarray)
  183. {
  184. GetTextFunc111(monaco);
  185. String text1 = MonacoText111;
  186. text1 = text1.Replace(firstarray, secondarray);
  187. SetText111(monaco, text1);
  188. }
  189.  
  190. private void SetText111(WebBrowser monaco, String text) // monaco as chosen webbrowser and text as which string you want to get text from
  191. {
  192. monaco.Document.InvokeScript("SetText", new object[]
  193. {
  194. text
  195. });
  196. }
  197. private String MonacoText111;
  198. private void GetTextFunc111(WebBrowser monaco) // monaco as webbrowser name (get text from) and text as the object you want to set text to
  199. {
  200. try
  201. {
  202. HtmlDocument document = monaco.Document;
  203. string scriptName = "GetText";
  204. object[] args = new string[0];
  205. object obj = document.InvokeScript(scriptName, args);
  206. string script = obj.ToString();
  207. MonacoText111 = script;
  208. }
  209. catch (Exception)
  210. {
  211. MessageBox.Show("Exception: Invalid WebBrowser / use string 'MonacoText' to assign values (object.text = MonacoText)");
  212. }
  213. }
  214.  
  215. public void credits(String yourusername)
  216. {
  217. MessageBox.Show("Monaco API made by _King_#5471, exception debugging made by _King_#5471, public variabled suggested by FBI blyat AKA Project Cocaine. And best of all, used by the great " + yourusername + "!");
  218. }
  219. }
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement