b站动态设置

调整b站动态首页得展示

  1. // ==UserScript==
  2. // @name b站动态设置
  3. // @namespace https://gf.qytechs.cn/
  4. // @license MIT
  5. // @version 0.1
  6. // @description 调整b站动态首页得展示
  7. // @author byhgz
  8. // @match *://t.bilibili.com/*
  9. // @require https://code.jquery.com/jquery-3.5.1.min.js
  10. // @require https://gf.qytechs.cn/scripts/462234-message/code/Message.js?version=1170653
  11. // @icon https://static.hdslb.com/images/favicon.ico
  12. // @grant GM_registerMenuCommand
  13. // @grant GM_addStyle
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // ==/UserScript==
  17.  
  18. const Util = {
  19. addGMMenu(text, func, shortcutKey = null) {
  20. return GM_registerMenuCommand(text, func, shortcutKey);
  21. },
  22. addStyle(cssStyleStr) {
  23. GM_addStyle(cssStyleStr);
  24. },
  25. setData(key, content) {
  26. GM_setValue(key, content);
  27. },
  28. getData(key, defaultValue) {
  29. return GM_getValue(key, defaultValue);
  30. },
  31. }
  32.  
  33. const Layout={
  34. addMenu(){
  35. $("body").append(`<div style="position: fixed; left: 90%;top: 10%;z-index: 2024">
  36. <button id="isShowMainPanel">只显示主内容</button>
  37. </div>`);
  38. }
  39. }
  40.  
  41. const LocalData = {
  42. isTrendsItemsTwoColumn() {
  43. return Util.getData("trendsItemsTwoColumn", false);
  44. },
  45. setTrendsItemsTwoColumn(is) {
  46. Util.setData("trendsItemsTwoColumn", is === true);
  47. }
  48. }
  49.  
  50. const Trends = {
  51. setitemsCss() {
  52. Util.addStyle(`
  53. .bili-dyn-up-list__content{
  54. display:flex;
  55. flex-flow:row wrap;
  56. }`);
  57. },
  58. setStyleRichTextarea() {
  59. const i1 = setInterval(() => {
  60. const richTextArea = document.querySelector(".bili-rich-textarea");
  61. if (richTextArea === null) return;
  62. clearInterval(i1);
  63. try {
  64. $(richTextArea).css("max-height", "");
  65. Qmsg.success("已解锁发动态编辑框的最大可视内容!");
  66. } catch (e) {
  67. console.error("修改编辑框最大可视内容时出错!", e);
  68. }
  69. }, 1000);
  70. },
  71. topCssDisply: {
  72. //针对于整体布局的细调整
  73. body() {
  74. const interval = setInterval(() => {
  75. const leftTopUserE = document.querySelector(".left .bili-dyn-my-info");
  76. if (leftTopUserE === null) return;
  77. clearInterval(interval);
  78. leftTopUserE.remove();
  79. document.querySelector(".bili-dyn-home--member").style.justifyContent = 'space-between';
  80. $('aside').hide();
  81. document.querySelector("main").style.width = "100%";
  82. });
  83. const interval02 = setInterval(() => {
  84. const e = document.querySelectorAll(".bili-dyn-sidebar>*:nth-child(-n+2)");
  85. if (e.length === 0) return;
  86. clearInterval(interval02);
  87. e.forEach((value, key) => {
  88. value.remove();
  89. });
  90. console.log("已尝试移除个别多余的悬浮按钮");
  91. }, 500);
  92. }
  93. },
  94. };
  95.  
  96. function extracted() {
  97. const i2 = setInterval(() => {
  98. const tempList = document.querySelectorAll(".bili-dyn-list__items>.bili-dyn-list__item");
  99. if (tempList.length === 0) return;
  100. clearInterval(i2);
  101. //调整动态列表的布局方式为类似网格
  102. Util.addStyle(`
  103. .bili-dyn-list__items{
  104. column-count: 2;
  105. }
  106. .bili-dyn-list__items>*{
  107. page-break-inside: avoid;
  108. }
  109. `);
  110. }, 500);
  111. }
  112.  
  113. (function () {
  114. 'use strict';
  115. const url = window.location.href;
  116. const title = document.title;
  117. Util.addGMMenu("动态首页动态展示双列显示开关", () => {
  118. const b = confirm("是否开启动态首页动态展示双列显示?\n当前状态:" + (LocalData.isTrendsItemsTwoColumn() === true ? "开" : "关"));
  119. LocalData.setTrendsItemsTwoColumn(b);
  120. alert(`已设置状态:${b ? "开" : "关"}`);
  121. });
  122. if (!(url.startsWith("https://t.bilibili.com/") && title.startsWith("动态首页-哔哩哔哩"))) {
  123. return;
  124. }
  125. console.log("=========动态首页=========");
  126. const i1 = setInterval(() => {
  127. const tab = document.querySelector(".bili-dyn-up-list__content");
  128. if (tab === null) return;
  129. clearInterval(i1);
  130. Trends.setitemsCss();
  131. Qmsg.success("已修改切换动态用护栏展示");
  132. $(tab).children(".bili-dyn-up-list__item").click(() => {
  133. extracted();
  134. });
  135. }, 1000);
  136. Trends.setStyleRichTextarea();
  137. Trends.topCssDisply.body();
  138. if (LocalData.isTrendsItemsTwoColumn()) {
  139. extracted();
  140. }
  141. Layout.addMenu();
  142. $("#isShowMainPanel").click((e) => {
  143. const target = e.target;
  144. const aside = $('aside');
  145. const bodyMain = document.querySelector("main");
  146. if (target.textContent === "只显示主内容") {
  147. target.textContent = "显示左右中内容";
  148. aside.show();
  149. bodyMain.style.width = "724px";
  150. } else {
  151. target.textContent = "只显示主内容";
  152. aside.hide();
  153. bodyMain.style.width = "100%";
  154. }
  155. });
  156.  
  157. })();

QingJ © 2025

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