forked from win4r/AISuperDomain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cs
2338 lines (2111 loc) · 104 KB
/
MainPage.xaml.cs
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* This class represents the main page of the application, which serves as the entry point and central hub for user interaction.
* It manages various AI integrations, web views, and user prompts, providing a comprehensive interface for accessing and controlling AI tools.
*
* The MainPage class includes several key components:
* - A collection of WebView objects for displaying different AI interfaces.
* - A dictionary for storing and managing AI configurations and prompts.
* - Methods for handling user input, navigating between AI tools, and processing data from AI responses.
*
* This class is part of a larger application designed to facilitate AI integration and automation, providing users with a seamless experience across multiple AI platforms.
*/
namespace AIIntegrator;
using System; // 引入System命名空间
using System.Collections.Generic; // 引入System.Collections.Generic命名空间
using System.Text; // 引入System.Text命名空间
using System.Threading.Tasks; // 引入System.Threading.Tasks命名空间
using Microsoft.Maui.Controls; // 引入Microsoft.Maui.Controls命名空间
using Newtonsoft.Json; // 引入Newtonsoft.Json命名空间
using Newtonsoft.Json.Linq; // 引入Newtonsoft.Json.Linq命名空间
using SixLabors.ImageSharp.Formats.Png; // 引入SixLabors.ImageSharp.Formats.Png命名空间
/**
* This class represents the main page of the application, which serves as the entry point and central hub for user interaction.
* It manages various aspects such as AI platform selection, text input and editing, and interaction with web-based AI tools.
* The page includes functionality for loading different AI platforms, translating text, and merging AI-generated content.
* It also handles user prompts and settings, and provides options for checking for updates and accessing information about the application.
*/
/**
* Initializes the main page of the application, setting up the web views, configuration dictionaries,
* and event handlers for various user interactions.
*
* This method performs the following tasks:
* 1. Initializes the web views and their visibility based on the window count configuration.
* 2. Loads AI platform URLs based on the stored platform names.
* 3. Sets up event handlers for text changes in the editor, selection of AI platforms,
* and other UI interactions.
* 4. Manages the display and interaction of prompts and settings.
*
* @param None
* @return None
*/
/**
* This class represents the main page of the application, which serves as the entry point and central hub for user interaction.
* It manages the configuration and prompts for various AI platforms, handles user input, and controls the visibility of web views.
* The class includes methods for loading AI URLs, managing user prompts, and handling various user actions such as text editing, AI selection, and translation.
* It also includes JavaScript strings for interacting with web views and handling specific AI functionalities.
*/
/// <summary>
/// Initializes the main page, setting up the web views and their configurations.
/// </summary>
public MainPage()
{
InitializeComponent();
// ... (rest of the constructor code)
}
public partial class MainPage : ContentPage
{
const string js_poe_AiPaint_hide_aside_js =
"document.querySelectorAll('aside').forEach(function(aside){aside.style.display='none';});";
const string js_poe_copybutton =
"document.oncontextmenu=function(){return false;};document.querySelectorAll('aside').forEach(function(aside){aside.style.display='none';});setTimeout(function(){function waitForElement(selector,callback){const poll=setInterval(function(){const el=document.querySelectorAll('.ChatStopMessageButton_stopButton__QOW41');if(el.length<=0){callback(el);}},500);}waitForElement('button>img',function(el){const allMarkdownContainers=document.querySelectorAll('.ChatMessage_chatMessage__xkgHx:not(.processed)');const lastTwoContainers=Array.from(allMarkdownContainers).slice(-1);lastTwoContainers.forEach((paragraphElement)=>{const copyButton=document.createElement('button');copyButton.textContent='复制📑';copyButton.style.marginLeft='5px';paragraphElement.appendChild(copyButton);copyButton.addEventListener('click',function(event){const targetParagraph=event.currentTarget.parentElement;let childNodes=Array.from(targetParagraph.childNodes);childNodes=childNodes.filter(node=>!node.classList.contains('ChatMessage_botMessageHeader__8yA1R'));let textToCopy='';childNodes.forEach(node=>{textToCopy+=node.textContent;});textToCopy=textToCopy.replace('复制📑','');const tempInput=document.createElement('textarea');tempInput.value=textToCopy;document.body.appendChild(tempInput);tempInput.select();document.execCommand('copy');document.body.removeChild(tempInput);});paragraphElement.classList.add('processed');copyButton.classList.add('Button_buttonBase__Bv9Vx');});});},5000);";
//禁用右键的JavaScript
const string js_rightClick = ""; // @"(function() { document.oncontextmenu = function() { return false; }; })();";
private const string _gitUpdate = "https://github.com/win4r/AISuperDomain/releases";
List<string> _platformNames = new List<string>();
//存储配置文件
// 文件路径
string filePath = string.Empty;
// 提示文件路径
string filePromptsPath = string.Empty;
// 窗口计数文件路径
string fileWindowsCountPath = string.Empty;
// 窗口计数
private string _windows_count = "0";
// 切换窗口计数的方法
private Action<string> toggleWindowsCount;
// 配置字典
Dictionary<string, string[]> dicConfiguration;
// 提示字典
Dictionary<string, string> dicPrompts;
//string js_poe = $@"document.querySelector('textarea').value = '[message]';document.querySelector('textarea').dispatchEvent(new KeyboardEvent('keydown', {{ keyCode: 13, bubbles: true }}));";
// 定义一个字符串变量js_bing_image,用于存储JavaScript代码
/* 字符串插值:$@"..."是C#中的字符串插值语法,允许在字符串中直接嵌入变量或表达式。在这里,[message]是一个占位符,表示搜索框中要输入的内容。 */
string js_bing_image =
$@"(function(){{let t;document.querySelector('#sb_form_q').value='[message]';clearTimeout(t);t=setTimeout(()=>{{document.querySelector('#create_btn_c').click();}},1000);}})();";
string js_poe =
$@"((textarea = document.querySelector('textarea'), lastValue = textarea.value, textarea.value = '[message]', inputEvent = new Event('input', {{bubbles: true }}), inputEvent.simulated = true, tracker = textarea._valueTracker, tracker ? tracker.setValue(lastValue) : void 0, textarea.dispatchEvent(inputEvent), enterKeyEvent = new KeyboardEvent('keydown', {{key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true, cancelable: true }}), textarea.dispatchEvent(enterKeyEvent)));";
string js_bito =
$@"document.querySelector('#user_input1').value = '[message]';document.querySelector('#user_input1').dispatchEvent(new KeyboardEvent('keydown', {{ keyCode: 13, bubbles: true }}));";
string js_huggingChat =
$@"(document.querySelector('textarea').value = '[message]', document.querySelector('textarea').dispatchEvent(new Event('input', {{bubbles: true }})), document.querySelector('textarea').dispatchEvent(new KeyboardEvent('keydown', {{key: 'Enter' }})))";
string js_bing_update =
$@"(document.querySelector('cib-serp').shadowRoot.querySelector('#cib-action-bar-main').shadowRoot.querySelector('cib-text-input').shadowRoot.querySelector('#searchbox').value = '[message]', document.querySelector('cib-serp').shadowRoot.querySelector('#cib-action-bar-main').shadowRoot.querySelector('cib-text-input').shadowRoot.querySelector('#searchbox').dispatchEvent(new Event('input', {{bubbles: true }})), document.querySelector('cib-serp').shadowRoot.querySelector('#cib-action-bar-main').shadowRoot.querySelector('cib-text-input').shadowRoot.querySelector('#searchbox').dispatchEvent(new KeyboardEvent('keydown', {{key: 'Enter' }})));";
string js_bing_compose =
$@"(() => {{ document.querySelector('#prompt_text').value = '[message]'; document.querySelector('#prompt_text').dispatchEvent(new Event('input', {{bubbles: true}})); setTimeout(() => document.querySelector('#compose_button').click(), 500); }})();";
//string js_bing = $@"(document.querySelector('cib-serp').shadowRoot.querySelector('#cib-action-bar-main').shadowRoot.querySelector('#searchbox').value = '[message]', document.querySelector('cib-serp').shadowRoot.querySelector('#cib-action-bar-main').shadowRoot.querySelector('#searchbox').dispatchEvent(new Event('input', {{bubbles: true }})), document.querySelector('cib-serp').shadowRoot.querySelector('#cib-action-bar-main').shadowRoot.querySelector('#searchbox').dispatchEvent(new KeyboardEvent('keydown', {{key: 'Enter' }})))";
string js_bard =
$@"(function(p, btn) {{ p.innerText = '[message]', setTimeout(function() {{ btn.click(); }}, 500); }})(document.querySelector('.ql-editor.textarea > p'), document.querySelector('.send-button.mdc-icon-button'));";
string js_lmsys =
$@"(function() {{ var buttons = document.querySelectorAll('button.svelte-kqij2n'); if(buttons.length >= 3) {{ buttons[2].click(); }} var elements = document.querySelectorAll('.svelte-1ed2p3z'); elements.forEach(function(element) {{ element.style.display = 'none'; }}); var textareas = document.querySelectorAll('textarea[data-testid=""textbox""]'); var buttons = [document.querySelector('#component-28'), document.querySelector('#component-65'), document.querySelector('#component-89')]; textareas.forEach(function(textarea) {{ textarea.value = '[message]'; textarea.dispatchEvent(new Event('input', {{ bubbles: true }})); }}); setTimeout(function() {{ buttons.forEach(function(button) {{ if(button) button.click(); }}); }}, 1000); }})();";
string js_BLOOM =
$@"((textarea = document.querySelector('textarea'), lastValue = textarea.value, textarea.value = '[message]', inputEvent = new Event('input', {{bubbles: true }}), inputEvent.simulated = true, tracker = textarea._valueTracker, tracker ? tracker.setValue(lastValue) : void 0, textarea.dispatchEvent(inputEvent), enterKeyEvent = new KeyboardEvent('keydown', {{key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true, cancelable: true }}), textarea.dispatchEvent(enterKeyEvent)));";
//string js_StableLM = $@"((t) => (t.value = '[message]', t.dispatchEvent(new Event('input', {{bubbles: true}})), t.dispatchEvent(new KeyboardEvent('keydown', {{key: 'Enter'}})), document.querySelector('#component-10').click()))(document.querySelector('textarea'));";
//string js_theb = $@"document.querySelector('textarea').value = '[message]';document.querySelector('textarea').dispatchEvent(new Event('input',{{bubbles:!0}}));document.querySelector('textarea').dispatchEvent(new KeyboardEvent('keydown',{{keycode:13}}));setTimeout(function(){{document.querySelector('.n-button__icon').click();document.querySelectorAll('button')[24].click()}},1e3);";
string js_openai =
$@"(function() {{ var textarea = document.querySelector('textarea'); textarea.value = '[message]'; textarea.dispatchEvent(new Event('input', {{bubbles: true}})); setTimeout(function() {{ textarea.dispatchEvent(new KeyboardEvent('keydown', {{key: 'Enter', code: 'Enter', keyCode: 13, charCode: 13, which: 13, bubbles: true, cancelable: true}})); }}, 1000); }})();";
string js_slackClaude =
$@"(function(){{let myDiv=document.querySelector('.ql-editor');let myP=myDiv.querySelector('p');let button=document.querySelector('.c-button-unstyled.c-icon_button.c-icon_button--size_small.c-wysiwyg_container__button.c-wysiwyg_container__button--send.c-icon_button--default');myP.textContent='[message]';let inputEvent=new Event('input',{{bubbles:true}});myP.dispatchEvent(inputEvent);myDiv.addEventListener('input',function(e){{}});setTimeout(function(){{button.click();}},1000);}})();";
string js_llama =
$@"((textarea = document.querySelector('textarea'), lastValue = textarea.value, textarea.value = '[message]', inputEvent = new Event('input', {{bubbles: true }}), inputEvent.simulated = true, tracker = textarea._valueTracker, tracker ? tracker.setValue(lastValue) : void 0, textarea.dispatchEvent(inputEvent), enterKeyEvent = new KeyboardEvent('keydown', {{key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true, cancelable: true }}), textarea.dispatchEvent(enterKeyEvent)));";
//string js_claude = $@"(function(){{document.querySelector('.is-empty.is-editor-empty').innerHTML = '[message]'; setTimeout(function() {{ var elem = document.querySelector('.ProseMirror.p-4'); if (elem) {{ var event = new KeyboardEvent('keydown', {{ 'key': 'Enter', 'code': 'Enter', 'keyCode': 13, 'which': 13, 'bubbles': true, 'cancelable': true }}); elem.dispatchEvent(event); }} else {{ console.log(""Element not found""); }} }}, 1000);}}());";
string js_claude2 =
$@"(function(){{document.querySelector('.is-empty.is-editor-empty').innerHTML = '[message]'; setTimeout(function(){{var elem = document.querySelector('.ProseMirror p'); if (elem) {{var event = new KeyboardEvent('keydown', {{'key': 'Enter', 'code': 'Enter', 'keyCode': 13, 'which': 13, 'bubbles': true, 'cancelable': true}}); setTimeout(function(){{elem.dispatchEvent(event);}}, 500); setTimeout(function(){{var buttonElement = document.querySelector('button[aria-label=""Send Message""]'); if (buttonElement) {{buttonElement.click();}}}}, 1000);}}}}, 1000);}}());";
string js_perplexityAI_characterAI =
$@"(function(){{let a=document.querySelector('textarea'),b=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,""value"").set;b.call(a,'[message]');let c=new Event('input',{{bubbles:true}});a.dispatchEvent(c);let d=new KeyboardEvent('keydown',{{bubbles:true,key:'Enter',keyCode:13}});a.dispatchEvent(d)}})();document.querySelector('.aspect-square.h-10').click();";
private string js_ImaginewithMetaAI =
$@"(function() {{ let textarea = document.querySelector('textarea'); let nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, ""value"").set; nativeInputValueSetter.call(textarea, '[message]'); let inputEvent = new Event('input', {{ bubbles: true}}); textarea.dispatchEvent(inputEvent); let enterEvent = new KeyboardEvent('keydown', {{ bubbles: true, key: 'Enter', keyCode: 13 }}); textarea.dispatchEvent(enterEvent); }})();";
string js_qianwen =
$@"(function(){{let a=document.querySelector('textarea'),b=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,'value').set;b.call(a,'[message]');a.dispatchEvent(new Event('input',{{bubbles:true}}));a.dispatchEvent(new KeyboardEvent('keydown',{{bubbles:true,key:'Enter',keyCode:13}}));}})();";
string js_yiyan =
$@"(function(){{let a=document.querySelector('textarea'),b=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,'value').set;b.call(a,'[message]');a.dispatchEvent(new Event('input',{{bubbles:true}}));a.dispatchEvent(new KeyboardEvent('keydown',{{bubbles:true,key:'Enter',keyCode:13}}));document.querySelector("".VAtmtpqL"").click();}})();";
string js_tiangong =
$@"(function() {{ document.querySelector('textarea').value = '[message]'; document.querySelector('textarea').dispatchEvent(new Event('input', {{ bubbles: true }})); document.querySelector('textarea').dispatchEvent(new KeyboardEvent('keydown', {{ key: 'Enter' }})); document.querySelector('.sureSubmitDiv').click(); }})();";
string js_xinghuo =
$@"(function(){{ let a=document.querySelector('div#ask-window > textarea'),b=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,'value').set;b.call(a,'[message]');a.dispatchEvent(new Event('input',{{ bubbles:true }}));a.dispatchEvent(new KeyboardEvent('keydown',{{ bubbles:true,key:'Enter',keyCode:13 }}));document.querySelector('div#ask-window > div.ask-window_send__xTavC').click(); }})();";
string js_chatglm =
$@"(function(){{var t=document.querySelector('textarea'),l=t.value,i=new Event('input',{{bubbles:true}});t.value='[message]',i.simulated=true,t._valueTracker&&t._valueTracker.setValue(l),t.dispatchEvent(i),t.dispatchEvent(new KeyboardEvent('keydown',{{key:'Enter',code:'Enter',keyCode:13,which:13,bubbles:true,cancelable:true}})),setTimeout(function(){{document.querySelector('div#search-input-box img').click();}},1000);}})();";
string js_doubao =
$@"(function(){{ let a=document.querySelector('div#root textarea'),b=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,'value').set;b.call(a,'[message]');a.dispatchEvent(new Event('input',{{ bubbles:true }}));a.dispatchEvent(new KeyboardEvent('keydown',{{ bubbles:true,key:'Enter',keyCode:13 }})); }})();";
string js_baiduAI =
$@"((t) => {{ if(t) {{ t.value = '[message]'; t.dispatchEvent(new Event('input', {{bubbles: true}})); t.dispatchEvent(new KeyboardEvent('keydown', {{key: 'Enter', bubbles: true, cancelable: true}})); setTimeout(() => {{ const s = document.querySelector('.c-icon.text-input-send_2GgoL'); s && s.click(); }}, 1000); }} }})(document.querySelector('textarea'));";
string js_perplexity_lab =
$@"((textarea = document.querySelector('textarea'), lastValue = textarea.value, textarea.value = '[message]', inputEvent = new Event('input', {{bubbles: true }}), inputEvent.simulated = true, tracker = textarea._valueTracker, tracker ? tracker.setValue(lastValue) : void 0, textarea.dispatchEvent(inputEvent), enterKeyEvent = new KeyboardEvent('keydown', {{key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true, cancelable: true }}), textarea.dispatchEvent(enterKeyEvent)));";
const string js_falcon_180b =
@"((t) => (t.value = '[message]', t.dispatchEvent(new Event('input', {bubbles: true})), t.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter'})), document.querySelector('#component-17').click()))(document.querySelector('textarea'));";
const string ini_js_lmsys =
@"(function() { var intervalId = setInterval(function() { var elements = document.querySelectorAll('.svelte-1ed2p3z'); if(elements.length > 0) { elements.forEach(function(element) { element.style.display = 'none'; }); clearInterval(intervalId); } }, 2000); })();";
// const string _ini_js_bingUnOfficial = "(function(){var checkElement = setInterval(function() { var elem = document.querySelector('.n-notification-container.n-notification-container--scrollable.n-notification-container--top-right'); if (elem) { elem.style.display = 'none'; clearInterval(checkElement); } }, 1000);}());";
const string _ini_js_poe = "";
const string _ini_js_perplexity_lab =
"(function() {let select = document.getElementById('lamma-select'); select.value = '[item]'; let event = new Event('change', { bubbles: true, cancelable: true });select.dispatchEvent(event);})();";
const string _ini_js_openai =
"(document.querySelector('.flex-shrink-0.overflow-x-hidden.dark.bg-gray-900') && window.getComputedStyle(document.querySelector('.flex-shrink-0.overflow-x-hidden.dark.bg-gray-900')).visibility === 'visible') && (function() { var rectElement = document.querySelector('rect'); var event = new MouseEvent('click', { 'view': window, 'bubbles': true, 'cancelable': true }); rectElement.dispatchEvent(event); })();";
const string _ini_js_bloom =
"document.querySelector('header.MuiBox-root.mui-style-x4qroo').style.display = 'none';document.querySelector('div.MuiBox-root.mui-style-1mrd89u').style.display = 'none';";
const string _ini_js_Bito =
"document.getElementById('bitoai_title_content1').style.display = 'none';document.getElementById('signedInDivWeb').style.display = 'none'; document.querySelector('div[style*='text-align: center;font-size: 13px;color: #fff;padding-bottom: 5px']').style.display = 'none';";
const string _ini_js_freechatgpt =
"(function() { Array.from(document.getElementsByClassName('info')).forEach(function(element) { element.style.display = 'none'; }); })();";
const string _ini_js_LLAM2 =
$@"(function() {{ var intervalId = setInterval(function() {{ var tabNav = document.querySelector('.tab-nav'), noticeMarkdown = document.querySelector('#notice_markdown'), component25 = document.querySelector('#component-25'), builtWithSvelte = document.querySelector('.built-with.svelte-1lyswbr'); if (tabNav && noticeMarkdown && component25 && builtWithSvelte) {{ tabNav.style.display = 'none', noticeMarkdown.style.display = 'none', component25.style.display = 'none', builtWithSvelte.style.display = 'none', clearInterval(intervalId); }} }}, 1000); }})();";
const string _ini_baiduAi =
$@"(() => setTimeout(() => document.querySelector('.ai-entry-right').click(), 3000))();";
const string _ini_falcon_180b =
$@"(function check() {{ var el = document.querySelector('#component-6'); el ? el.style.display = 'none' : setTimeout(check, 1000); }})();";
const string js_poe_getContent =
@"(() => { let elements = document.querySelectorAll('.Markdown_markdownContainer__Tz3HQ'); return elements[elements.length - 1].textContent; })()";
const string js_claude2_getContent =
@"(() => { let elements = document.querySelectorAll('.contents'); return elements[elements.length - 2].textContent; })()";
const string js_bard_getContent =
@"(() => { let elements = document.querySelectorAll('.markdown.markdown-main-panel'); return elements[elements.length - 1].textContent; })()";
const string js_llama2_getContent =
@"(() => { let elements = document.querySelectorAll('.text-sm'); return elements[elements.length - 1].textContent; })()";
const string js_openai_getContent =
@"(() => (document.querySelectorAll('.markdown.prose')[document.querySelectorAll('.markdown.prose').length - 1].textContent))();";
List<string> listCommonJs = new List<string>();
List<WebView> webViews;
List<WebView> webViews_Visiable = new();
List<List<WebView>> webViewGroups;
public MainPage()
{
InitializeComponent();
string documentsPath = Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData
);
// 存储AI名称的文件路径
filePath = Path.Combine(documentsPath, "aime_taConfig.txt");
filePromptsPath = Path.Combine(documentsPath, "ini_prompts_1.txt");
fileWindowsCountPath = Path.Combine(documentsPath, "ini_windows_count.txt");
//toggleWindowsCount = (fileWindowsCountPath) =>
//{
// _windows_count = _windows_count == "0" ? "1" : "0";
// File.WriteAllText(fileWindowsCountPath, _windows_count);
//};
toggleWindowsCount = (fileWindowsCountPath) =>
File.WriteAllText(
fileWindowsCountPath,
_windows_count =
_windows_count == "0" ? "1"
: _windows_count == "1" ? "2"
: "0"
);
// 创建一个字典来保存 WebView 对象
Dictionary<string, WebView> webViewsDic = new Dictionary<string, WebView>();
//设置窗口数量配置文件,读取并存储到_windows_count里
if (File.Exists(fileWindowsCountPath))
{
_windows_count = File.ReadAllText(fileWindowsCountPath).ToString();
}
else
{
File.WriteAllText(fileWindowsCountPath, "0");
}
Enumerable
.Range(1, 24)
.ToList()
.ForEach(i =>
{
var webView = new WebView();
Grid.SetRow(webView, 0);
Grid.SetColumn(
webView,
_windows_count == "0" ? (i - 1) % 2 * 6
: _windows_count == "1" ? (i - 1) % 4 * 3
: (i - 1) % 6 * 2
);
myGrid.Children.Insert(0, webView);
webViewsDic.Add($"webView_{i}", webView);
});
#region 初始化数据和提示词
dicConfiguration = new Dictionary<string, string[]>()
{
{
"bing-DALLE",
new string[] { "https://www.bing.com/create", "", "", js_bing_image, "" }
},
{
"ImaginewithMetaAI",
new string[] { "https://imagine.meta.com/", "", "", js_ImaginewithMetaAI, "" }
},
{
"poe-Playground-v2",
new string[]
{
"https://poe.com/Playground-v2",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-StableDiffusionXL",
new string[]
{
"https://poe.com/StableDiffusionXL",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-Midjourneycreators",
new string[]
{
"https://poe.com/Midjourneycreators",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-DSLR-SDXL",
new string[]
{
"https://poe.com/DSLR-SDXL",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-VanGoghPaint",
new string[]
{
"https://poe.com/VanGoghPaint",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-ImaginePixar",
new string[]
{
"https://poe.com/ImaginePixar",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-Paper_model",
new string[]
{
"https://poe.com/Paper_model",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-TattooArt",
new string[]
{
"https://poe.com/TattooArt",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-EasyMovieScene",
new string[]
{
"https://poe.com/EasyMovieScene",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-ImageReal",
new string[]
{
"https://poe.com/ImageReal",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-ImgXL_AnimeArtwork",
new string[]
{
"https://poe.com/ImgXL_AnimeArtwork",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-Photo_magic",
new string[]
{
"https://poe.com/Photo_magic",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-ImgXL_Hyperrealistic",
new string[]
{
"https://poe.com/ImgXL_Hyperrealistic",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-ImgXL_Pro3DModel",
new string[]
{
"https://poe.com/ImgXL_Pro3DModel",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-Kashinano",
new string[]
{
"https://poe.com/Kashinano",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-RealXL",
new string[]
{
"https://poe.com/RealXL",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-AnimeXL",
new string[]
{
"https://poe.com/AnimeXL",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-CinematicXL",
new string[]
{
"https://poe.com/CinematicXL",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-VisualXL",
new string[]
{
"https://poe.com/VisualXL",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"poe-Model_ImagesE",
new string[]
{
"https://poe.com/Model_ImagesE",
js_poe_AiPaint_hide_aside_js,
_ini_js_poe,
js_poe,
"",
}
},
{
"openai-dall-e",
new string[]
{
"https://chat.openai.com/g/g-2fkFE8rbu-dall-e",
_ini_js_openai,
"",
js_openai,
"",
}
},
{ "lmsys", new string[] { "https://chat.lmsys.org/", "", ini_js_lmsys, js_lmsys, "" } },
{
"falcon-180b",
new string[]
{
"https://tiiuae-falcon-180b-demo.hf.space/",
"",
_ini_falcon_180b,
js_falcon_180b,
"",
}
},
{
"poeChatGPT",
new string[]
{
"https://poe.com/ChatGPT",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeGemini-Pro",
new string[]
{
"https://poe.com/Gemini-Pro",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeMixtral-8x7B-Chat",
new string[]
{
"https://poe.com/Mixtral-8x7B-Chat\n",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poe-GPT-3.5-Turbo",
new string[]
{
"https://poe.com/GPT-3.5-Turbo",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeGPT-3.5-Turbo-Instruct",
new string[]
{
"https://poe.com/GPT-3.5-Turbo-Instruct",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeAssistant",
new string[]
{
"https://poe.com/Assistant",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeClaude",
new string[]
{
"https://poe.com/Claude-instant",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poe-Web-Search",
new string[]
{
"https://poe.com/Web-Search",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeClaude-instant-100k",
new string[]
{
"https://poe.com/Claude-instant-100k",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeClaude2-100k",
new string[]
{
"https://poe.com/Claude-2-100k",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poePaLM",
new string[]
{
"https://poe.com/Google-PaLM",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeLLAMA2",
new string[]
{
"https://poe.com/Llama-2-70b",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeCode-Llama-34b",
new string[]
{
"https://poe.com/Code-Llama-34b",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeCode-Llama-13b",
new string[]
{
"https://poe.com/Code-Llama-13b",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeCode-Llama-7b",
new string[]
{
"https://poe.com/Code-Llama-7b",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeGPT4",
new string[]
{
"https://poe.com/GPT-4",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeChatGPT-16k",
new string[]
{
"https://poe.com/ChatGPT-16k",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeGPT-4-32k",
new string[]
{
"https://poe.com/GPT-4-32k",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeSolar-0-70b",
new string[]
{
"https://poe.com/Solar-0-70b",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeChatGLM",
new string[]
{
"https://poe.com/ChatGLM",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeVicuna-13B-V13",
new string[]
{
"https://poe.com/Vicuna-13B-V13",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poe-Dalle-3-Generator",
new string[]
{
"https://poe.com/Dalle-3-Generator",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeMidjourney",
new string[]
{
"https://poe.com/Midjourney",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeStableSDXL",
new string[]
{
"https://poe.com/Stable-SDXL-prompter",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeDallE3_S",
new string[]
{
"https://poe.com/DallE3_S",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poe-DALLEbot",
new string[]
{
"https://poe.com/DALLEbot",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeMidjourney1000",
new string[]
{
"https://poe.com/Midjourney1000",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poeHumanWrite",
new string[]
{
"https://poe.com/HumanWrite",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poe-fw-mistral-7b",
new string[]
{
"https://poe.com/fw-mistral-7b",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"poe-CIaude-2-100k",
new string[]
{
"https://poe.com/CIaude-2-100k",
js_poe_copybutton,
_ini_js_poe,
js_poe,
js_poe_getContent,
}
},
{
"copilot",
new string[]
{
"https://copilot.microsoft.com/",
js_rightClick,
"",
js_bing_update,
js_poe_getContent,
}
},
{
"copilotMirror",
new string[]
{
"https://harry-zklcdc-go-proxy-bingai.hf.space/web/?showconv=1#/",
js_rightClick,
"",
js_bing_update,
js_poe_getContent,
}
},
{
"Bloom",
new string[]
{
"https://api.together.xyz/bloom-chat?preview=1",
js_rightClick,
_ini_js_bloom,
js_BLOOM,
js_poe_getContent,
}
},
{
"bingAI_creative",
new string[]
{
"https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx&sydconv=1",
js_rightClick,
"",
js_bing_update,
js_poe_getContent,
}
},
{
"bingAI_balance",
new string[]
{
"https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx&sydconv=1",
js_rightClick,
"",
js_bing_update,
js_poe_getContent,
}
},
{
"bing_chat_edge",
new string[]
{
"https://edgeservices.bing.com/edgesvc/chat?udsframed=1&form=SHORUN&clientscopes=chat,noheader,udsedgeshop,channelstable,&setlang=zh-cn&lightschemeovr=1",
js_rightClick,
"",
js_bing_update,
"",
}
},
{
"bing_chat_edge_2",
new string[]
{
"https://edgeservices.bing.com/edgesvc/chat?udsframed=1&form=SHORUN&clientscopes=chat,noheader,udsedgeshop,channelstable,&setlang=zh-cn&lightschemeovr=1",
js_rightClick,
"",
js_bing_update,
"",
}
},
{
"bing_chat_compose",
new string[]
{
"https://edgeservices.bing.com/edgesvc/compose?udsframed=1&form=SHORUN&clientscopes=chat,noheader,coauthor,channelstable,&lightschemeovr=1&setlang=zh-cn",
js_rightClick,
"",
js_bing_compose,
"",
}
},
{
"perplexity-codellama-34b-instruct",
new string[]
{
"https://labs.perplexity.ai/",
"",
_ini_js_perplexity_lab.Replace("[item]", "codellama-34b-instruct"),
js_perplexity_lab,
"",
}
},
{
"perplexity-llama-2-13b-chat",
new string[]
{
"https://labs.perplexity.ai/",
"",
_ini_js_perplexity_lab.Replace("[item]", "llama-2-13b-chat"),
js_perplexity_lab,
"",
}
},
{
"perplexity-llama-2-70b-chat",
new string[]
{
"https://labs.perplexity.ai/",
"",
_ini_js_perplexity_lab.Replace("[item]", "llama-2-70b-chat"),
js_perplexity_lab,
"",
}
},
{
"perplexity-mistral-7b-instruct",
new string[]
{
"https://labs.perplexity.ai/",
"",
_ini_js_perplexity_lab.Replace("[item]", "mistral-7b-instruct"),
js_perplexity_lab,
"",
}
},
{
"Bito",
new string[]
{
"https://alpha.bito.co/bitoai/",
js_rightClick,
_ini_js_Bito,
js_bito,
js_poe_getContent,
}
},
{
"Bard",
new string[]
{
"https://bard.google.com/chat",
js_rightClick,
"",
js_bard,
js_bard_getContent,
}