0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

カスタムスクリプトでDOMをいじる

Last updated at Posted at 2023-04-05

◆入力したテキストを引用タグ<blockquote>で囲う

カスタムスクリプト
<script>
document.addEventListener("DOMContentLoaded", async () => {
if (document.body.dataset.hasCompiledHtml) { return; }

MTBlockEditorSetCompiledHtml(`<blockquote>
${document.body.innerHTML}
</blockquote>`);

});
</script>

MTBlockEditorSetCompiledHtml

MTBlockEditorSetCompiledHtml(html)で、出力するhtmlを指定することができます。

テンプレートリテラルでDOMを作成

入力内容「${document.body.innerHTML}」をそのまま持ってきて、前後に<blockquote>を。

MTBlockEditorSetCompiledHtml(`
<blockquote>
${document.body.innerHTML}
</blockquote>
`);

◆入力前のテキストをいじる

カスタムスクリプト
<script>
document.addEventListener("DOMContentLoaded", async () => {
    if (!document.body.dataset.hasCompiledHtml) {
        document.body.textContent = "あああああああ";
        Object.assign(document.body.style, {textAlign:"center",paddingTop:"40px"});
    }
});
</script>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?