Fix text-autospace.js: Scope hanla Tags to Blog Content
Preface
Previously, I applied text-autospace.js to add spaces between Chinese and English, and I have kept using it until now; the display effect is quite good.
Today I wanted to have AI modify it so that it only takes effect in the main body of blog posts; it should not take effect in other parts of the page, such as gadgets.
AI analysis told me that this script adds hanla tags to the entire body element of the HTML.
What? (I was shocked; I had never thought about what this script was doing underneath. I only knew the final display effect by looking at it with my eyes.)
Confirm the current situation
Implemented according to the original project's instructions. (I have already implemented it, omitted)
Open a page in the browser, such as https://zelikk.blogspot.com/2026/09/chrome-edge-extension-maximize-video-button.html
F12 Developer Tools
On the Elements page, use Ctrl+F to search for hanla
I cannot imagine why, for so long before, my blog did not seem to have any problems when used.
Furthermore, if hanla tags are inserted inside h1, h2, h3, ... tags in the main body of blog posts, that is interfering information for programs such as crawlers and agents.
Fix the problem
Agent-oriented development
Hermes connects to the free public site agentrouter's deepseek-v4-flash
The following quote boxes are all natural language I sent to the Agent
* I only wrote the key requirement description information and omitted the test feedback information. This development was not a simple one-shot. I did not have the final effect in mind from the beginning either. I gradually clarified my requirements throughout the process.
你改一份 新的
只处理 加了 class=han-la 的 元素
发现问题
当页面 加载 时, 在script 中 添加了
基于 https://github.com/crazypeace/text-autospace.js/blob/master/text-autospace.js
进一步的, 对于 h1, h2, h3, ... 等 元素, 也不添加 hanla
Result
1. Insert hanla tags only into the content of elements that have been set with class="han-la"
2. Do not insert hanla tags into the content of tags such as script, h1, h2, h3, ...
Github
https://crazypeace.github.io/text-autospace.js/