Families.AutoWriter
1.0.0.0
Families 콘텐츠를 반복 작업 없이 작성·등록하도록 돕는 자동화 작성 도구입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
PromptInjector.cs
이 파일의 문서화 페이지로 가기
1
namespace
FamiliesAutoWriter.Services
;
2
11
public
static
class
PromptInjector
12
{
37
public
static
string
BuildInjectScript
(
string
prompt)
38
{
39
// JSON 문자열로 안전하게 이스케이프
40
var escaped = System.Text.Json.JsonSerializer.Serialize(prompt);
41
42
return
$$
""
"
43
(async function() {
44
const text = {{escaped}};
45
46
// ── Claude.ai ──────────────────────────────────────────────
47
// ProseMirror contenteditable div
48
let el = document.querySelector('div[contenteditable="
true
"].ProseMirror')
49
?? document.querySelector('[contenteditable="
true
"][data-placeholder]')
50
?? document.querySelector('div[contenteditable="
true
"]');
51
52
if (el) {
53
el.focus();
54
// 기존 내용 지우기
55
document.execCommand('selectAll', false, null);
56
document.execCommand('delete', false, null);
57
// 텍스트 입력
58
document.execCommand('insertText', false, text);
59
await new Promise(r => setTimeout(r, 300));
60
// 전송 버튼 클릭 시도
61
const sendBtn = document.querySelector('button[data-testid="
send-button
"]')
62
?? document.querySelector('button[aria-label*="
Send
"]')
63
?? document.querySelector('button[type="
submit
"]');
64
if (sendBtn && !sendBtn.disabled) { sendBtn.click(); return 'sent:claude'; }
65
// Enter로 전송 (shift 없이)
66
el.dispatchEvent(new KeyboardEvent('keydown', {key:'Enter', keyCode:13, bubbles:true}));
67
return 'sent:claude-enter';
68
}
69
70
// ── ChatGPT ────────────────────────────────────────────────
71
let gptEl = document.getElementById('prompt-textarea')
72
?? document.querySelector('textarea[placeholder*="
Message
"]')
73
?? document.querySelector('textarea[data-id]');
74
75
if (gptEl) {
76
gptEl.focus();
77
const nativeSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
78
nativeSetter.call(gptEl, text);
79
gptEl.dispatchEvent(new Event('input', {bubbles:true}));
80
await new Promise(r => setTimeout(r, 300));
81
const btn = document.querySelector('button[data-testid="
send-button
"]')
82
?? document.querySelector('button[aria-label="
Send prompt
"]');
83
if (btn && !btn.disabled) { btn.click(); return 'sent:chatgpt'; }
84
gptEl.dispatchEvent(new KeyboardEvent('keydown', {key:'Enter', keyCode:13, bubbles:true}));
85
return 'sent:chatgpt-enter';
86
}
87
88
// ── Gemini ─────────────────────────────────────────────────
89
let gemEl = document.querySelector('rich-textarea .ql-editor')
90
?? document.querySelector('.ql-editor[contenteditable="
true
"]')
91
?? document.querySelector('textarea.input-area')
92
?? document.querySelector('p[data-placeholder]');
93
94
if (gemEl) {
95
gemEl.focus();
96
document.execCommand('selectAll', false, null);
97
document.execCommand('delete', false, null);
98
document.execCommand('insertText', false, text);
99
await new Promise(r => setTimeout(r, 400));
100
const btn = document.querySelector('button.send-button')
101
?? document.querySelector('button[aria-label*="
전송
"]')
102
?? document.querySelector('button[aria-label*="
Send
"]')
103
?? document.querySelector('mat-icon[data-mat-icon-name="
send
"]')?.closest('button');
104
if (btn) { btn.click(); return 'sent:gemini'; }
105
gemEl.dispatchEvent(new KeyboardEvent('keydown', {key:'Enter', keyCode:13, bubbles:true}));
106
return 'sent:gemini-enter';
107
}
108
109
return 'no-input-found';
110
})();
111
"
""
;
112
}
113
}
FamiliesAutoWriter.Services
Definition
PostWriterService.cs:7
FamiliesAutoWriter.Services.PromptInjector
Definition
PromptInjector.cs:12
FamiliesAutoWriter.Services.PromptInjector.BuildInjectScript
static string BuildInjectScript(string prompt)
Definition
PromptInjector.cs:37
Services
PromptInjector.cs
다음에 의해 생성됨 :
1.17.0