seo TDK自动生成

    <script>
        (() => {
            setTimeout(() => {
                document.querySelectorAll("meta[name]").forEach(e => {
                    if (e.name == 'description' && e.content.trim() == "") {
                        e.content = document.querySelectorAll(".post-content")[0].innerText.replaceAll('\n', '').substring(0, 150) + "..."
                    }
                    console.warn(e.contains);
                    if (e.name == 'keywords' && e.content.trim() == "") {
                        e.content = "关键词"
                    }
                })
                if (document.title.trim() == "")
                    document.title = document.querySelectorAll('.display-1')[0].innerText
            }, 200);
        })()
    </script>
posted @ 2024-01-31 16:07  lambertlt  阅读(13)  评论(0编辑  收藏  举报