basyura's blog

あしたになったらほんきだす。

inkdrop - ウインドウタイトルをクリアする

Windows 版だとウインドウタイトルに記事のタイトルが出るようになった。チラつくのが気になるのでクリアするようにしてみる。

init.js

inkdrop.onEditorLoad(() => {
  const ele = document.querySelector(".editor-header-title-input input");
  const observer = new MutationObserver((_) => {
    setTimeout(() => {
      inkdrop.window.setTitle("");
    }, 300);
  });
  observer.observe(ele, {
    attributes: true,
  });
  setInterval(() => {
    inkdrop.window.setTitle("");
  }, 3000);
});

記事切替だけではなく編集中にもタイトルが書き換わるので定期的に実行するようにした。