Coze Bot Style for App

Let Coze Bot Style of App better!

当前为 2024-06-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Coze Bot Style for App
  3. // @namespace https://www.velhlkj.com/
  4. // @version 1.0.2
  5. // @description Let Coze Bot Style of App better!
  6. // @author Velade
  7. // @match https://www.coze.com/store/bot/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @run-at document-body
  11. // @license Apache 2.0
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const style = document.createElement('style');
  18. style.textContent = `
  19. /*官方阴影*/
  20. .ULoOs2TMkJkb2BgT_MKa {
  21. display: none !important;
  22. }
  23. /*新对话按钮*/
  24. .NyvVfPwFXFYvQFyXUtTl {
  25. padding-left: 0 !important;
  26. }
  27. /*标题列*/
  28. .nZxnu8KzOis7qKnDx66E {
  29. position: fixed !important;
  30. top: 5px !important;
  31. right: 5px !important;
  32. width: 80px !important;
  33. height: 40px !important;
  34. filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5)) !important;
  35. }
  36.  
  37. .nZxnu8KzOis7qKnDx66E > div:first-child {
  38. display: none !important;
  39. }
  40.  
  41. .nZxnu8KzOis7qKnDx66E > div:nth-child(2) > div:nth-child(2){
  42. display: none !important;
  43. }
  44. /*对话区域主体*/
  45. .O4fwdEnt3QgzBjrYtohO {
  46. -webkit-mask: linear-gradient(180deg,hsla(0,0%,100%,0) 5px, #fff calc(8.11% + 5px), #fff 91.89%, hsla(0,0%,100%,0)) !important;
  47. mask: linear-gradient(180deg,hsla(0,0%,100%,0) 5px, #fff calc(8.11% + 5px), #fff 91.89%, hsla(0,0%,100%,0)) !important;
  48. }
  49. /*底部声明:改为导航栏占位*/
  50. .pStAbHgTdAlDVUlpMOGP {
  51. opacity: 0 !important;
  52. height: 5px !important;
  53. }
  54. /*斜体样式*/
  55. .flow-markdown-body em.vel-em-action {
  56. display: block !important;
  57. clear: both !important;
  58. color: #FF69B4 !important;
  59. font-style: normal !important;
  60. }
  61. .flow-markdown-body em.vel-em-other {
  62. display: inline-block !important;
  63. clear: none !important;
  64. color: #FF69B4 !important;
  65. font-style: normal !important;
  66. }
  67. `;
  68. document.head.appendChild(style);
  69.  
  70. let observer = new MutationObserver(mutations=>{
  71. mutations.forEach(mutation=>{
  72. if(mutation.type === 'childList' || mutation.type === "characterData"){
  73. mutation.addedNodes.forEach(node=>{
  74. if(!node.querySelectorAll) return;
  75. if(node.matches(".paragraph-element") && node.innerHTML.match(/\*[\((].+?[\))]\*/)){
  76. node.innerHTML = node.innerHTML.replaceAll(/\*[\((]/g,"<em>(").replaceAll(/[\))]\*/g, ")</em>");
  77. }else {
  78. node.querySelectorAll(".paragraph-element").forEach(n=>{
  79. if(n.innerHTML.match(/\*[\((].+?[\))]\*/)) n.innerHTML = n.innerHTML.replaceAll(/\*[\((]/g,"<em>(").replaceAll(/[\))]\*/g, ")</em>");
  80. })
  81. }
  82. console.log(node);
  83. if(node.tagName.toLowerCase() == "em") {
  84. if(node.textContent.match(/^[\((].+?[\))]$/)) { node.textContent = node.textContent.replaceAll(/[\(\)()]/g,""); node.classList.add("vel-em-action"); }
  85. else node.classList.add("vel-em-other");
  86. }else if(node.matches(".math-inline")){
  87. node.parentElement.textContent = node.textContent;
  88. }else{
  89. node.querySelectorAll(`em:not(.vel-em-action, .vel-em-other)`).forEach(n=>{
  90. if(n.textContent.match(/^[\((].+?[\))]$/)) { n.textContent = n.textContent.replaceAll(/[\(\)()]/g,""); n.classList.add("vel-em-action"); }
  91. else n.classList.add("vel-em-other");
  92. })
  93. }
  94. })
  95. }
  96. })
  97. });
  98. const config = { childList: true, subtree: true,characterData: true };
  99. const targetNode = document.body;
  100. observer.observe(targetNode, config);
  101. })();