Greasy Fork is available in English.

bilibili强化

B站自动宽屏 超宽屏 自动洗脑循环 自动展开简介区 屏蔽充电鸣谢 屏蔽视频暂停和结束广告 自动将简介区网址改成超连结

  1. // ==UserScript==
  2. // @name bilibili强化
  3. // @namespace https://greasyfork.org/scripts/437650
  4. // @version 4.4
  5. // @description B站自动宽屏 超宽屏 自动洗脑循环 自动展开简介区 屏蔽充电鸣谢 屏蔽视频暂停和结束广告 自动将简介区网址改成超连结
  6. // @author fmnijk
  7. // @match https://www.bilibili.com/*
  8. // @exclude https://www.bilibili.com/festival/*
  9. // @icon https://www.google.com/s2/favicons?domain=bilibili.com
  10. // @grant GM_addStyle
  11. // @license MIT
  12. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  13. // ==/UserScript==
  14.  
  15. /*主函数*/
  16. (function() {
  17. 'use strict';
  18.  
  19. /*不影响首页*/
  20. if (window.location.href == 'https://www.bilibili.com/'){
  21. return false;
  22. }
  23.  
  24. /*自動寬屏*/
  25. autowide();
  26.  
  27. /*自動網頁全屏*/
  28. //autofull();
  29.  
  30. /*超寬屏 需啟用自動寬屏才能用 (beta)*/
  31. //ultrawide();
  32.  
  33. /*自動洗脑循环*/
  34. autoloop();
  35.  
  36. /*自动展开简介区*/
  37. autounfold();
  38.  
  39. /*屏蔽充电鸣谢*/
  40. blockelecpanel();
  41.  
  42. /*屏蔽视频暂停和结束广告*/
  43. blockendpanel();
  44.  
  45. /*自动将简介区网址改成超连结*/
  46. autohyperlink();
  47.  
  48. /*快轉後自動暫停*/
  49. //autopause();
  50. })();
  51.  
  52. /*定時器*/
  53. function setIntervalX(callback, delay, maxrepeate) {
  54. var count = 0;
  55. var intervalID = window.setInterval(function () {
  56.  
  57. if (++count === maxrepeate) {
  58. window.clearInterval(intervalID);
  59. }
  60.  
  61. callback();
  62. }, delay);
  63. }
  64.  
  65. function setIntervalY(callback, isfinish, delay, maxrepeate) {
  66. var count = 0;
  67. var intervalID = window.setInterval(function () {
  68.  
  69. if (isfinish() || ++count === maxrepeate) {
  70. window.clearInterval(intervalID);
  71. }
  72.  
  73. callback();
  74. }, delay);
  75. }
  76.  
  77. /*自動寬屏*/
  78. function autowide() {
  79. $('.bilibili-player-video > video, .bilibili-player-video > bwp-video, .bpx-player-video-wrap > video')?.[0]?.addEventListener('playing', function () {
  80. $('.bpx-player-ctrl-btn.bpx-player-ctrl-wide').click();
  81. }, {once : true});
  82. }
  83.  
  84. /*自動網頁全屏*/
  85. function autofull() {
  86. $('.bilibili-player-video > video, .bilibili-player-video > bwp-video, .bpx-player-video-wrap > video')?.[0]?.addEventListener('playing', function () {
  87. $('.bpx-player-ctrl-btn.bpx-player-ctrl-web').click();
  88. }, {once : true});
  89. }
  90.  
  91. /*超寬屏*/
  92. function ultrawide(){
  93. var styles = `
  94. /*超寬屏影片*/
  95. #player_module, #bilibili-player{
  96. left: 0vw !important;
  97. right: 0vw !important;
  98. max-height: 50vw !important;
  99. margin: 0 !important;
  100. padding: 0 !important;
  101. position: unset !important;
  102. }
  103.  
  104. #app{
  105. width: 100vw !important;
  106. padding-left: 0 !important;
  107. }
  108.  
  109. .l-con, .v-wrap{
  110. width: 100vw !important;
  111. padding: 0 !important;
  112. }
  113.  
  114. /*bangumi*/
  115. .plp-l{
  116. padding-top: 0 !important;
  117. }
  118.  
  119. .plp-r{
  120. margin-top: 0 !important;
  121. }
  122.  
  123. /*適配超窄視窗*/
  124. .l-con{
  125. min-width: 638px !important;
  126. }
  127.  
  128. /*優化位於超寬屏影片上方的元素 縮小其高度和占用區域 增加視覺寬度*/
  129. .international-header{
  130. min-height: 36px !important;
  131. }
  132.  
  133. .mini-header{
  134. height: 36px !important;
  135. }
  136.  
  137. #internationalHeader > div > div{
  138. padding: 0 !important;
  139. }
  140.  
  141. .bili-avatar{
  142. width: 36px !important;
  143. height: 36px !important;
  144. }
  145.  
  146. #viewbox_report{
  147. padding-top: 12px !important;
  148. height: 80px !important;
  149. }
  150.  
  151. /*超寬屏模式下屏蔽退出寬屏按鈕*/
  152. /*.bilibili-player-video-btn.bilibili-player-video-btn-widescreen{
  153. display: none !important;
  154. }
  155.  
  156. .squirtle-widescreen-wrap.squirtle-block-wrap{
  157. display: none !important;
  158. }*/
  159.  
  160. /*適配沒有大會員的情況*/
  161. #player_module, #bilibili-player{
  162. min-height: 400px !important;
  163. }
  164.  
  165. #danmukuBox{
  166. display:block !important;
  167. }
  168. `;
  169.  
  170. GM_addStyle(styles);
  171.  
  172. window.onresize = function() {
  173. setTimeout(function(){
  174. tryultrawide();
  175. },100);
  176. }
  177.  
  178. /*分頁在背景開啟的情況,點擊分頁時運行*/
  179. window.onfocus = function() {
  180. setIntervalX(tryultrawide, 100, 50);
  181. }
  182.  
  183. setIntervalX(tryultrawide, 100, 50);
  184. }
  185.  
  186. function tryultrawide() {
  187. $('#bilibili-player').css('width', $('#app').css('width'));
  188. $('#bilibili-player').css('width', $('.v-wrap').css('width'));
  189.  
  190. $('#player_module').css('width', $('#bilibili-player').css('width'));
  191.  
  192. //先auto再設定成auto的height數值,可以和max-height同時生效
  193. $('#bilibili-player').css('height', 'auto');
  194. $('#bilibili-player').css('height', $('#bilibili-player').css('height'));
  195.  
  196. $('#player_module').css('height', $('#bilibili-player').css('height'));
  197.  
  198. $('#playerWrap').css('height', $('#bilibili-player').css('height'));
  199. $('#danmukuBox').css('margin-top', 'calc(' + $('#bilibili-player').css('height') + ' + 10px)');
  200.  
  201. /*適配超長標題*/
  202. $('h1').css('max-width', 'calc(' + $('.v-wrap').css('width') + ' - 350px)');
  203. }
  204.  
  205. /*自動洗脑循环*/
  206. function autoloop() {
  207. var styles = `
  208. /*屏蔽結尾圖片才不會蓋住重播*/
  209. .bpx-player-ending-wrap {
  210. display: none !important;
  211. }
  212. `;
  213.  
  214. GM_addStyle(styles);
  215.  
  216. $('.bilibili-player-video > video, .bilibili-player-video > bwp-video, .bpx-player-video-wrap video')?.[0]?.addEventListener('ended', function () {
  217. /*自动连播時不自動洗脑循环,立即開始下一部影片*/
  218. if($('.next-button > .switch-button')?.[0]?.className.indexOf(' on') != -1){
  219. $('.next-play a')?.[0]?.click();
  220. return false;
  221. }
  222. this.currentTime = 0;
  223. this.play();
  224. }, false);
  225. }
  226.  
  227. /*自动展开简介区*/
  228. function autounfold() {
  229. var styles = `
  230. /*屏蔽收起*/
  231. #v_desc > div.toggle-btn > span {
  232. display: none !important;
  233. }
  234. `;
  235.  
  236. GM_addStyle(styles);
  237.  
  238. setIntervalY(tryautounfold, isunfold, 100, 50);
  239. }
  240.  
  241. function tryautounfold() {
  242. $('.toggle-btn').each(function() {
  243. if ($(this).text()?.indexOf('展开更多') != -1){
  244. $(this).click();
  245. }
  246. });
  247. }
  248.  
  249. function isunfold() {
  250. $('.toggle-btn').each(function() {
  251. if ($(this).text()?.indexOf('展开更多') != -1){
  252. return true;
  253. }
  254. });
  255. return false;
  256. }
  257.  
  258. /*屏蔽充电鸣谢*/
  259. function blockelecpanel(){
  260. var styles = `
  261. /*屏蔽充电鸣谢*/
  262. .bilibili-player-electric-panel, .bpx-player-electric-panel {
  263. display: none !important;
  264. }
  265. `;
  266.  
  267. GM_addStyle(styles);
  268.  
  269. $('.bpx-player-video-wrap video')?.[0]?.addEventListener('ended', function () {
  270. setIntervalY(tryskipelecpanel, isskipelecpanel, 100, 50);
  271. }, true);
  272. }
  273.  
  274. function tryskipelecpanel() {
  275. $('.bilibili-player-electric-panel-jump-content, .bpx-player-electric-jump')?.[0]?.click();
  276. }
  277.  
  278. function isskipelecpanel() {
  279. return false;
  280. if ($('.bilibili-player-electric-panel-jump-content, .bpx-player-electric-jump')){
  281. $('.bilibili-player-electric-panel-jump-content, .bpx-player-electric-jump')?.[0]?.click();
  282. return true;
  283. }
  284. return false;
  285. }
  286.  
  287. /*屏蔽视频暂停和结束广告*/
  288. function blockendpanel(){
  289. var styles = `
  290. /*屏蔽视频暂停和结束广告*/
  291. .bilibili-player-ending-panel, .bpx-player-ending-panel {
  292. display: none !important;
  293. }
  294. `;
  295.  
  296. GM_addStyle(styles);
  297. }
  298.  
  299. /*自动将简介区网址改成超连结*/
  300. function autohyperlink(){
  301. $('.bilibili-player-video > video, .bilibili-player-video > bwp-video')?.[0]?.addEventListener('playing', function () {
  302.  
  303. const $ = document.querySelector.bind(document);
  304.  
  305. const upCom = $("#v_desc > div.desc-info.desc-v2.open > span"); // uploader comment
  306.  
  307. const str = upCom.innerHTML;
  308.  
  309. const newStr = str.replace(/(<a href=")?((https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)))(">(.*)<\/a>)?/gi, function () {
  310. return '<a href="' + arguments[2] + '">' + (arguments[7] || arguments[2]) + '</a>'
  311. });
  312.  
  313. upCom.innerHTML = newStr;
  314.  
  315. }, {once : true});
  316. }
  317.  
  318. /*快轉後自動暫停*/
  319. function autopause() {
  320. let video = $('.bilibili-player-video > video, .bilibili-player-video > bwp-video, .bpx-player-video-wrap > video')?.[0];
  321. video?.addEventListener('seeked', function () {
  322. video?.addEventListener('playing', function () {
  323. video?.pause();
  324. }, {once : true});
  325. }, {once : false});
  326. }
  327.