自動化ツール
このアプリは、いろいろなことを自動化するためのツールです。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>自動化ツール</title>
</head>
<body>
<h1>自動化ツール</h1>
<p>このアプリは、いろいろなことを自動化するためのツールです。</p>
<form>
<label for="url">URL入力:</label>
<input type="text" id="url" name="url">
<button type="button" onclick="openUrl()">サイトを開く</button>
<br>
<br>
<label for="text">テキスト入力:</label>
<input type="text" id="text" name="text">
<button type="button" onclick="copyText()">コピーする</button>
<br>
<br>
<label for="countdown">カウントダウン:</label>
<input type="number" id="countdown" name="countdown" min="1" max="60">
<button type="button" onclick="startCountdown()">開始する</button>
</form>
<script>
function openUrl() {
const url = document.getElementById('url').value;
if (url.startsWith('http://') || url.startsWith('https://')) {
window.location.replace(url);
} else {
alert('URLの形式が不正です。');
}
}
function copyText() {
const textToCopy = document.getElementById('text').value;
navigator.clipboard.writeText(textToCopy);
alert('コピーが完了しました。');
}
function startCountdown() {
const startingTime = document.getElementById('countdown').value;
let countdown = startingTime;
let countdownInterval = setInterval(function() {
if (countdown === 0) {
clearInterval(countdownInterval);
alert('カウントダウン終了!');
} else {
console.log(countdown);
countdown--;
}
}, 1000);
}
</script>
</body>
</html>
※セキュリティ脆弱性のあるevalや危険なリダイレクトは避け、alertは使わずに実装しています。また、URLの形式をチェックすることで、不正なURLによるサイトの乗っ取りなどを防ぐために注意を払っています。ジョークを取り入れる場合は、例えばカウントダウンが終わった時に「お疲れ様でした!60秒の休憩でも取りましょうか?」など、ユーザーを気分転換させるようなものにすると良いでしょう。