<script>
/* 字号调节 A- / A / A+（阅读体验） */
(function () {
  'use strict';
  function initFontSize() {
    var postBody = document.querySelector('.post-body');
    if (!postBody || document.getElementById('font-size-control')) return;
    var bar = document.createElement('div');
    bar.id = 'font-size-control';
    bar.className = 'font-size-control';
    var labels = [['A-', -1], ['A', 0], ['A+', 1]];
    var current = 1.0;
    labels.forEach(function (item) {
      var btn = document.createElement('button');
      btn.textContent = item[0];
      btn.title = item[0] === 'A-' ? '减小字号' : item[0] === 'A+' ? '增大字号' : '恢复默认';
      btn.addEventListener('click', function () {
        if (item[1] === 0) current = 1.0;
        else current = Math.min(1.4, Math.max(0.8, current + item[1] * 0.1));
        postBody.style.fontSize = current + 'em';
      });
      bar.appendChild(btn);
    });
    document.body.appendChild(bar);
  }
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', initFontSize);
  } else {
    initFontSize();
  }
})();
</script>
