/* HBMIC translation config (client: hbmic-translation-client.js) */ window.HBMIC_TRANSLATION_CONFIG = { endpoint: "https://hbmic-translation-1025124869583.asia-northeast3.run.app", enabled: true }; /* 11/11 11:15 line-break guard for every page: a new sentence never starts as the last word of a line, a short last word never sits alone, a " กค " separator never starts a line (non-breaking spaces). Runs again when page scripts change text. */ (function(){var NB=String.fromCharCode(160);var BLK='p,li,dd,dt,figcaption,small,label,h1,h2,h3,h4';var SKIP='.ch,.roll,.hb-roll,script,style,textarea,input,select,[contenteditable]'; function lastText(b){var w=document.createTreeWalker(b,4,null),n,l=null;while(n=w.nextNode()){if(/\S/.test(n.nodeValue))l=n}return l} function fixNode(t){var p=t.parentElement;if(!p||p.closest(SKIP))return;var b=p.closest(BLK);if(!b||!b.closest('#hbMain'))return;var s=t.nodeValue,o=s; s=s.replace(/[ ]([กค|])[ ]/g,NB+'$1 ');s=s.replace(/([.!?])[ ]+(\S+)[ ](?=\S)/g,function(m,a,c){return a+' '+c+NB}); if(t===lastText(b)){s=s.replace(/[ ](\S{1,6})\s*$/,function(m,c){return NB+c})} if(s!==o)t.nodeValue=s} function run(root){var w=document.createTreeWalker(root||document.body,4,null),n,a=[];while(n=w.nextNode())a.push(n);a.forEach(fixNode)} var q=null;function later(){if(q)return;q=setTimeout(function(){q=null;var m=document.getElementById('hbMain');if(m)run(m)},120)} function start(){var m=document.getElementById('hbMain');if(!m)return;run(m);try{new MutationObserver(later).observe(m,{childList:true,subtree:true,characterData:true})}catch(e){}} if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start);else start();})();