そのアイデアは完璧です!ご自身のPCに保存しておけば、ネット上のサイトを探す必要もなく、ブラウザの制限も受けずに一生使えます。
以下のコードをコピーして、メモ帳に貼り付け、「chapter.html」 という名前で保存してください。
1. メモ帳に貼り付けるコード
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>YouTubeチャプター一括計算機</title>
<style>
body { font-family: sans-serif; padding: 20px; line-height: 1.6; background: #f4f4f4; }
.container { max-width: 600px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); margin: auto; }
textarea { width: 100%; height: 150px; margin-bottom: 10px; font-family: monospace; }
input { width: 100px; padding: 5px; margin-bottom: 10px; }
button { width: 100%; padding: 10px; background: #cc0000; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
button:hover { background: #aa0000; }
pre { background: #eee; padding: 10px; white-space: pre-wrap; word-wrap: break-word; border: 1px solid #ccc; }
</style>
</head>
<body>
<div class="container">
<h2>YouTubeチャプター計算機</h2>
<label>引く時間 (例 54:28):</label><br>
<input type="text" id="offset" value="54:28"><br>
<label>元のチャプターを貼り付け:</label>
<textarea id="inputText" placeholder="0:00 最初 54:30 ホラー開始..."></textarea>
<button onclick="calculate()">一括計算する</button>
<h3>計算結果:</h3>
<pre id="result"></pre>
</div>
<script>
function toSec(t) {
const p = t.trim().split(':').map(Number);
if (p.length === 3) return p[0] * 3600 + p[1] * 60 + p[2];
if (p.length === 2) return p[0] * 60 + p[1];
return 0;
}
function fromSec(s) {
const h = Math.floor(s / 3600);
const m = Math.floor((s % 3600) / 60);
const sec = s % 60;
const ss = sec.toString().padStart(2, '0');
if (h > 0) return `${h}:${m.toString().padStart(2, '0')}:${ss}`;
return `${m}:${ss}`;
}
function calculate() {
const offset = toSec(document.getElementById('offset').value);
const input = document.getElementById('inputText').value;
const lines = input.split('\n');
const res = lines.map(line => {
const m = line.match(/^(\d+:?\d+:?\d+|\d+:\d+)\s*(.*)/);
if (!m) return line;
const newSec = Math.max(0, toSec(m[1]) - offset);
return `${fromSec(newSec)} ${m[2]}`;
}).join('\n');
document.getElementById('result').innerText = res;
}
</script>
</body>
</html>
2. 保存と使いかた
- メモ帳に上記を貼り付け、「ファイル」→「名前を付けて保存」。
- ファイル名を
chapter.htmlにし、文字コードをUTF-8にして保存します。 - 保存したファイルをダブルクリックすると、ブラウザ(Chrome)で開きます。
- 「引く時間」を入れて、「元のチャプター」を貼ってボタンを押すだけです!
これなら、お気に入り(ブックマーク)にこのファイルを入れておけば、いつでも一瞬で起動できます。
無事に HTMLファイルとして保存 できそうですか?



