coze-space-ui-for-mobile

**coze-space-ui-for-mobile**

目前为 2024-02-28 提交的版本。查看 最新版本

// ==UserScript==
// @name         coze-space-ui-for-mobile
// @description  **coze-space-ui-for-mobile**
// @namespace    https://github.com/SolidZORO
// @version      0.0.4
// @author       Jason Feng <[email protected]>
// @match        *://www.coze.com/space/**
// @run-at       document-start
// @icon         https://sf-coze-web-cdn.coze.com/obj/coze-web-sg/obric/coze/favicon.1970.png
// @grant        GM_log
// @license      MIT
// ==/UserScript==

const SCREEN_WIDTH = `${window.innerWidth}px`;

const myStyles = `

/* 右下角反馈图标 */
.feelgood {
  display: none !important;
}

.sidesheet-container {
  grid-template-columns: auto !important;
}

/* 每条回复 */
.sidesheet-container .flow-markdown-body {
  max-width: ${window.innerWidth - 47}px;
}


/* 调节 bot */
.sidesheet-container > div:nth-of-type(1),
.sidesheet-container > div:nth-of-type(2) {
  display: none;

}

/* 主要聊天框 */
.sidesheet-container > div:nth-of-type(3) {
 width: ${SCREEN_WIDTH};
 min-width: unset;
 max-width: unset;
}


.semi-portal[style*="z-index: 1000"] {
  display: none;
}

/* Char ToolsBar */
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(1) {
  display: none;
}

/* Char 聊天窗口 */
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) {
 width: 100%;
 min-width: unset;
 max-width: unset;
}

/* 每条回复-wrapper */
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) {
 padding: 0;
}



/* 每条回复 */
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div {
  flex-direction: row;
 width: auto;
 min-width: unset;
 max-width: unset;
}

/* 每条回复 div1 */
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div > div {
width: auto;
min-width: unset;
max-width: unset;
}

/* 每条回复 div1 问题 */
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div > div > div:nth-of-type(1),
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div > div > div:nth-of-type(1) > div {
width: auto;
min-width: unset;
max-width: unset;
}

/* 每条回复 div1 回答 */
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div > div > div:nth-of-type(2),
.sidesheet-container > div:nth-of-type(3) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div > div > div:nth-of-type(2) > div {
width: auto;
min-width: unset;
max-width: unset;
}

/* Char NavBar */
.semi-spin-children > div:nth-of-type(1) {
  display: none;
}

`;




function main(injectType) {
  console.log('🤖 UserScript injectType:', injectType);

  //
  //
  // style tag 注入
  const styleSheet = document.createElement('style');
  styleSheet.textContent = myStyles;
  document.head.appendChild(styleSheet);

  //
  //
  // 等待 html 变化执行 inline style 注入
  const htmlObserver = new MutationObserver(function (mutations) {


    // 只监听一次
    // if (document.documentElement.getAttribute('has-inject-style')) return;


    mutations.forEach(mutation => {
      console.log(mutation);

      if (mutation.attributeName === "style") {
        // 只监听一次
        document.documentElement.setAttribute('has-inject-style', `${
                Number(document.documentElement.getAttribute('has-inject-style') || 0) + 1
                                                    }`);
              document.documentElement.style.minWidth = SCREEN_WIDTH;
              document.documentElement.style.width = SCREEN_WIDTH;

              document.body.style.minWidth = SCREEN_WIDTH;
              document.body.style.width = SCREEN_WIDTH;
            }
          });
        });


        htmlObserver.observe(document.documentElement, {
          attributes: true,
          attributeOldValue: true,
          attributeFilter: ['style'],
        });
      }



//
//
// 等待 main 执行
if (document.readyState !== 'loading') {
  main('readyState');
} else {
  document.addEventListener('DOMContentLoaded', function (event) {
    main('DOMContentLoaded');
  });
}


QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址