// ==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 https://update.greasyfork.cloud/scripts/457033/%E3%80%90tanchat%E6%96%87%E6%9C%AC%E8%87%AA%E5%8A%A8%E6%8D%A2%E8%A1%8C%E4%BC%98%E5%8C%96%EF%BC%88%E7%94%A8%E6%88%B7%E6%A0%B7%E5%BC%8F%E7%89%88%EF%BC%89%E3%80%91.user.js // @updateURL https://update.greasyfork.cloud/scripts/457033/%E3%80%90tanchat%E6%96%87%E6%9C%AC%E8%87%AA%E5%8A%A8%E6%8D%A2%E8%A1%8C%E4%BC%98%E5%8C%96%EF%BC%88%E7%94%A8%E6%88%B7%E6%A0%B7%E5%BC%8F%E7%89%88%EF%BC%89%E3%80%91.meta.js // ==/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); } })();