// ==UserScript== // @name 【tanchat文本自动换行优化(用户样式版)】 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 为tanchat客户端加入hack.chat有但是一些衍生客户端没有的overflow-wrap CSS,以使难以分词的西文消息正确自动换行 // @author firetree // @license WTFPL // @grant GM_addStyle // @run-at document-start // @include /^(?:.+:\/\/tanchat.fun\/\?.*)$/ // @downloadURL none // ==/UserScript== (function() { let css = ` .message .text { overflow-wrap: break-word; /*Note: In contrast to word-break, overflow-wrap (word-wrap is now an alias of overflow-wrap) will only create a break if an entire word cannot be placed on its own line without overflowing. https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap I think this is a proper solution of too long messages without any spaces which may overflow the paragraph, though i dont know how official hack.chat client does the same thing.*/ } `; if (typeof GM_addStyle !== "undefined") { GM_addStyle(css); } else { const styleNode = document.createElement("style"); styleNode.appendChild(document.createTextNode(css)); (document.querySelector("head") || document.documentElement).appendChild(styleNode); } })();