<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>⚔️ Multi SNS Post</title>
<style>
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
background-color: #f4f5f7;
color: #333;
max-width: 500px;
margin: 0 auto;
padding: 20px;
}
h2 {
text-align: center;
color: #2c3e50;
}
textarea {
width: 100%;
height: 150px;
font-size: 16px;
padding: 15px;
border: 1px solid #ccc;
border-radius: 8px;
box-sizing: border-box;
resize: vertical;
margin-bottom: 15px;
}
button {
width: 100%;
padding: 15px;
font-size: 18px;
font-weight: bold;
background-color: #6f42c1;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.2s;
}
button:hover {
background-color: #5a32a3;
}
button:disabled {
background-color: #a58bce;
cursor: not-allowed;
}
#status {
margin-top: 15px;
text-align: center;
font-weight: bold;
min-height: 24px;
}
.success { color: #28a745; }
.error { color: #dc3545; }
</style>
</head>
<body>
<h2>Multi SNS Post</h2>
<textarea id="postText" placeholder="いまどうしてる?"></textarea>
<button id="submitBtn" onclick="postToSNS()">一斉送信する</button>
<div id="status"></div>
<script>
async function postToSNS() {
const textArea = document.getElementById('postText');
const text = textArea.value.trim();
const statusDiv = document.getElementById('status');
const btn = document.getElementById('submitBtn');
if (!text) {
statusDiv.textContent = '⚠️ テキストを入力してください。';
statusDiv.className = 'error';
return;
}
// === 設定項目 ===
// ここを変更する必要あり
const token = 'YOUR_TOKEN';
const owner = 'YOUR_OWNER';
const repo = 'YOUR_REPOSITORY';
const workflow = 'post.yml';
// ==============
// ボタンを無効化して連打防止
btn.disabled = true;
btn.textContent = '送信中...';
statusDiv.textContent = '';
statusDiv.className = '';
try {
const res = await fetch(`https://api.github.com/repos/${owner}/${repo}/actions/workflows/${workflow}/dispatches`, {
method: 'POST',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
ref: 'main',
inputs: { post_text: text }
})
});
if (res.ok) {
statusDiv.textContent = '✅ 投稿指示を送信しました!(数秒後に反映されます)';
statusDiv.className = 'success';
textArea.value = ''; // 成功したら入力欄を空にする
} else {
const err = await res.text();
statusDiv.textContent = `❌ エラー: ${res.status}`;
statusDiv.className = 'error';
console.error(err);
}
} catch (e) {
statusDiv.textContent = `❌ 通信エラー: ${e.message}`;
statusDiv.className = 'error';
} finally {
// ボタンを元の状態に戻す
btn.disabled = false;
btn.textContent = '一斉送信する';
}
}
</script>
</body>
</html>