哔哩哔哩(b站)播放页美化

播放页显示UID和注册时间,显示屏蔽设定和高级弹幕选项

2021-01-05 일자. 최신 버전을 확인하세요.

질문, 리뷰하거나, 이 스크립트를 신고하세요.
  1. // ==UserScript==
  2. // @name 哔哩哔哩(b站)播放页美化
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.6
  5. // @description 播放页显示UID和注册时间,显示屏蔽设定和高级弹幕选项
  6. // @author AN drew
  7. // @match https://game.bilibili.com/*
  8. // @match https://www.bilibili.com/video/*
  9. // @match https://www.bilibili.com/bangumi/*
  10. // @match https://www.bilibili.com/cinema/*
  11. // @match https://www.bilibili.com/documentary/*
  12. // @match https://www.bilibili.com/tv/*
  13. // @match https://www.bilibili.com/variety/*
  14. // @match https://member.bilibili.com/*
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. var openbarrage=0;
  19.  
  20. function v()
  21. {
  22. var scriptsArray = new Array();
  23. $.cachedScript = function (url, options) {
  24. //循环script标记数组
  25. for (var s in scriptsArray) {
  26. console.log(scriptsArray[s]);
  27. //如果某个数组已经下载到了本地
  28. if (scriptsArray[s]==url) {
  29. return { //则返回一个对象字面量,其中的done之所以叫做done是为了与下面$.ajax中的done相对应
  30. done: function (method) {
  31. if (typeof method == 'function'){ //如果传入参数为一个方法
  32. method();
  33. }
  34. }
  35. };
  36. }
  37. }
  38. //这里是jquery官方提供类似getScript实现的方法,也就是说getScript其实也就是对ajax方法的一个拓展
  39. options = $.extend(options || {}, {
  40. dataType: "script",
  41. url: url,
  42. cache:true //其实现在这缓存加与不加没多大区别
  43. });
  44. scriptsArray.push(url); //将url地址放入script标记数组中
  45. return $.ajax(options);
  46. };
  47.  
  48.  
  49. $.cachedScript('https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js').done(function () {
  50.  
  51. console.log("加载成功")
  52.  
  53. var uid = $.cookie("DedeUserID")
  54. if($.cookie('registration_id')==undefined)
  55. $.cookie('registration_id', uid, { expires: 365, path: "/", domain: "bilibili.com" });
  56.  
  57. if(window.location.href.indexOf("https://member.bilibili.com/x2/creative/h5/calendar/event?ts=0") > -1) //注册信息
  58. {
  59. var timer = setInterval(function(){
  60. if($("pre").length>0)
  61. {
  62. var str =$("pre").html()
  63. var json=JSON.parse(str);
  64. var unix =json['data']['pfs']['profile']['jointime']
  65.  
  66. var theday=new Date(unix*1000);
  67. var ly = parseInt(theday.getFullYear());
  68. var lm = parseInt(1+theday.getMonth());
  69. var ld = parseInt(theday.getDate());
  70. clearInterval(timer)
  71.  
  72. if($.cookie('registration_days')==undefined || $.cookie('registration_id')!=uid)
  73. {
  74. $.cookie('registration_days', ly+"-"+lm+"-"+ld, { expires: 365, path: "/", domain: "bilibili.com" });
  75. $.cookie('registration_id', uid, { expires: 365, path: "/", domain: "bilibili.com" });
  76. }
  77. }
  78. },100)
  79. }
  80. else if(window.location.href.indexOf("bangumi") > -1) //番剧
  81. {
  82. var t0 = setInterval(function(){
  83. if($(".coin-info").length > 0)
  84. {
  85. var coininfo = $(".coin-info").find("span").text()
  86. if(coininfo != "--")
  87. {
  88. $(".coin-info").find("span").attr("style","width:85px")
  89. $(".coin-info").find("span").text("投币 "+coininfo)
  90. $(".coin-info").attr("style","margin-right:20px")
  91. clearInterval(t0)
  92. }
  93. }
  94. },100)
  95. }
  96.  
  97. var u ='<span><span id="uid">&nbsp;UID:&nbsp;</span><span id="id">xxx&nbsp;</span></span>'
  98. var $uid =$(u)
  99. $uid.css({"background":"#7CD4F2",
  100. "color":"white",
  101. "font-size":"10px",
  102. "margin-right":"30px",
  103. "padding":"1px 1px 1px 1px",
  104. "width": "28px",
  105. "height": "14px"})
  106. var t ='<span><span id="registration-time"><a href="https://member.bilibili.com/x2/creative/h5/calendar/event?ts=0" target="_blank" style="color:#00A1D6;text-decoration: underline">查看注册天数</a></span><span id="time"></span></span>'
  107. var $time=$(t)
  108. $time.css({"font-size":"10px",
  109. "margin-left":"20px",
  110. "padding":"1px 1px 1px 1px",
  111. "width": "56px",
  112. "height": "14px"})
  113.  
  114. var t2 ='<span><span id="registration-time">&nbsp;注册时间:&nbsp;</span><span id="time">xxxx-xx-xx</span></span>'
  115. var $time2=$(t2)
  116. $time2.css({"background":"#6DC781",
  117. "color":"white",
  118. "font-size":"10px",
  119. "margin-left":"20px",
  120. "padding":"1px 1px 1px 1px",
  121. "width": "56px",
  122. "height": "14px"})
  123.  
  124. setInterval(function(){
  125. if($(".mini-avatar").length>0)
  126. {
  127. $(".mini-avatar").hover(function(){
  128. if($(".myinfo").length==0)
  129. {
  130. var $div = $(".coins").clone(true)
  131. $div.empty()
  132. $div.attr("class","myinfo")
  133. $div.css({"vertical-align":"top","margin-top":"5px"})
  134. $div.append($uid)
  135. if($.cookie("registration_days")!=undefined && $.cookie('registration_id')==uid)
  136. {
  137. $div.append($time2)
  138. $(".level-content").before($div)
  139. $("#time").text($.cookie("registration_days")+'\u00a0')
  140. }
  141. else
  142. {
  143. $div.append($time)
  144. $(".level-content").before($div)
  145. }
  146. if(uid!=undefined)
  147. $("#id").text(uid+" ")
  148. }
  149. })
  150. }
  151. })
  152. });
  153.  
  154. var table = 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF';
  155. var tr = {};
  156. for (var i = 0; i < 58; ++i) {
  157. tr[table[i]] = i;
  158. }
  159.  
  160. var s = [11,10,3,8,4,6];
  161. var xor = 177451812;
  162. var add = 8728348608;
  163.  
  164.  
  165. //AV、BV互转方法来自知乎:https://www.zhihu.com/question/381784377/answer/1099438784
  166.  
  167. function dec(x)
  168. {
  169. let r = 0;
  170. for (var i = 0; i < 6; i++)
  171. {
  172. r += tr[x[s[i]]] * (58 ** i);
  173. }
  174. return 'av' + String((r - add) ^ xor);
  175. }
  176. function enc(x)
  177. {
  178. x=(x^xor)+add;
  179. let r=['B','V',1, , ,4, ,1, ,7, , ];
  180. for (var i = 0; i < 6; i++)
  181. {
  182. r[s[i]]=table[parseInt(x/58**i)%58];
  183. }
  184. return r.join("");
  185. }
  186.  
  187. setInterval(function(){
  188. if(window.location.pathname.indexOf("BV") > -1 || window.location.pathname.indexOf("bv") > -1)
  189. {
  190. let pathname=window.location.pathname;
  191. let bv;
  192. if(pathname.indexOf("BV")>-1)
  193. bv=pathname.substring(window.location.pathname.lastIndexOf("/BV")+1).replace("/","");
  194. else
  195. bv=pathname.substring(window.location.pathname.lastIndexOf("/bv")+1).replace("/","");
  196. let av = dec(bv);
  197.  
  198. if($("#avid").length==0)
  199. {
  200. var $avid = $("<span id='avid'></span>");
  201. $avid.attr("style","background: #FB7299; color: white; font-size: 13px; vertical-align:middle; margin-left:10px; padding: 5px; border-radius:5px; ")
  202. $avid.text(av)
  203. $("#viewbox_report").children().eq(1).append($avid)
  204. }
  205. if($("#bvid").length==0)
  206. {
  207. var $bvid = $("<span id='bvid'></span>");
  208. $bvid.attr("style","background: #00A1D6; color: white; font-size: 13px; vertical-align:middle; margin-left:10px; padding: 5px; border-radius:5px; ")
  209. $bvid.text(bv.replace("BV","bv"))
  210. $("#viewbox_report").children().eq(1).append($bvid)
  211. }
  212. }
  213. else if(window.location.pathname.indexOf("av") > -1)
  214. {
  215. let av=window.location.pathname.substring(window.location.pathname.lastIndexOf("/av")+1).replace("/","");
  216. let bv = enc(av.substring(2));
  217.  
  218. if($("#avid").length==0)
  219. {
  220. let $avid = $("<span id='avid'></span>");
  221. $avid.attr("style","background: #FB7299; color: white; font-size: 13px; vertical-align:middle; margin-left:10px; padding: 5px; border-radius:5px; ")
  222. $avid.text(av)
  223. $("#viewbox_report").children().eq(1).append($avid)
  224. }
  225. if($("#bvid").length==0)
  226. {
  227. let $bvid = $("<span id='bvid'></span>");
  228. $bvid.attr("style","background: #00A1D6; color: white; font-size: 13px; vertical-align:middle; margin-left:10px; padding: 5px; border-radius:5px; ")
  229. $bvid.text(bv.replace("BV","bv"))
  230. $("#viewbox_report").children().eq(1).append($bvid)
  231. }
  232. }
  233.  
  234. $(".nav-search-keyword").attr("placeholder"," ");
  235. if($(".user-card-m").length > 0)
  236. {
  237. if($(".user-card-m .uuid").length==0)
  238. {
  239. var $uuid = $("<span class='uuid'></span>");
  240. $uuid.attr("style","background: rgb(124, 212, 242); color: white; font-size: 10px; vertical-align:middle; margin-left:4px; padding-left:2px; padding-right:5px; border-radius:4px; font-weight:normal ")
  241. $uuid.text(" UID: "+$(".user .name").attr("href").substring($(".user .name").attr("href").lastIndexOf("/")+1)+" ")
  242. $(".user-card-m .user").append($uuid)
  243. }
  244. }
  245. $(".user-card").each(function(){
  246. if($(this).find(".uuid").length==0)
  247. {
  248. var $uuid = $("<span class='uuid'></span>");
  249. $uuid.attr("style","background: rgb(124, 212, 242); color: white; font-size: 10px; vertical-align:middle; margin-left:4px; padding-left:2px; padding-right:5px; border-radius:4px; font-weight:normal ")
  250. $uuid.text(" UID: "+$(this).find(".user .name").attr("href").substring($(this).find(".user .name").attr("href").lastIndexOf("/")+1)+" ")
  251. $(this).find(".user").append($uuid)
  252. }
  253. })
  254. },1)
  255.  
  256. setInterval(function(){
  257. if($("#v_desc > div.btn").text().indexOf("展开更多") > -1)
  258. $("#v_desc > div.btn").click()
  259. $(".ops span").attr("style","margin-right:30px");
  260. $(".appeal-text").attr("style","margin-right:5px");
  261. $(".note-btn.note-btn__pink").attr("style","margin-right:0px");
  262. $(".share-pos").attr("style","width:520px")
  263.  
  264. if($(".ops .like").length > 0)
  265. {
  266. var liketext = $(".ops .like").contents().eq(-1).get(0).textContent
  267. if(liketext.indexOf("点赞")==-1)
  268. $(".ops .like").contents().eq(-1).get(0).textContent="点赞 "+liketext
  269. }
  270.  
  271. if($(".ops .collect").length > 0)
  272. {
  273. var collecttext = $(".ops .collect").contents().eq(-1).get(0).nodeValue
  274. if(collecttext.indexOf("收藏")==-1)
  275. $(".ops .collect").contents().eq(-1).get(0).nodeValue="收藏 "+collecttext
  276. }
  277.  
  278. if($(".ops .coin").length > 0)
  279. {
  280. var cointext = $(".ops .coin").contents().eq(-1).get(0).textContent
  281. if(cointext.indexOf("投币")==-1)
  282. $(".ops .coin").contents().eq(-1).get(0).textContent="投币 "+cointext
  283. }
  284.  
  285. if($(".ops .share").length > 0)
  286. {
  287. var sharetext = $(".ops .share").contents().eq(1).get(0).nodeValue
  288. if(sharetext.indexOf("分享")==-1)
  289. $(".ops .share").contents().eq(1).get(0).nodeValue="分享 "+sharetext
  290. }
  291.  
  292. },10)
  293.  
  294.  
  295. setInterval(function(){
  296. if($("#activity_vote").length>0)
  297. {
  298. $("#activity_vote").hide()
  299. }
  300. $(".video-page-game-card").hide()
  301. },10)
  302.  
  303.  
  304. setInterval(function(){
  305. if($(".pop-live.report-wrap-module.report-scroll-module").length>0)
  306. {
  307. $(".pop-live.report-wrap-module.report-scroll-module").hide()
  308. }
  309. },500)
  310.  
  311. var t1=setInterval(function(){
  312. if($(".members-info__header").find(".btn").length>0 && $(".members-info__header").find(".btn").text().indexOf("展开") > -1)
  313. {
  314. $(".members-info__header").find(".btn").click()
  315. clearInterval(t1)
  316. }
  317. },500)
  318.  
  319. if(openbarrage==1)
  320. {
  321. var t2=setInterval(function(){
  322. if($(".bui-collapse-arrow-text").length>0 && $(".bui-collapse-arrow-text").text().indexOf("展开") > -1)
  323. {
  324. $(".bui-collapse-arrow-text").click()
  325. clearInterval(t2)
  326. }
  327. },500)
  328. }
  329.  
  330. var t3=setInterval(function(){
  331. if($(".player-auxiliary-filter").length>0 )
  332. {
  333. $(".player-auxiliary-filter").find("i").hide()
  334. $(".player-auxiliary-filter").find("i").before($('<span class="player-auxiliary-filter-title" style="margin-left:10px">屏蔽设定</span>'))
  335. $(".player-auxiliary-filter").find("i").before($('<span class="player-auxiliary-filter-title" style="margin-left:10px">高级弹幕</span>'))
  336. $(".player-auxiliary-filter-title").css({"height":"35px","border-bottom": "none","text-decoration":"none", "z-index":"1000"})
  337. $(".player-auxiliary-filter span:first-child").addClass("on")
  338. $(".player-auxiliary-filter span:first-child").css({"border-bottom": "2px solid #32AAFF"})
  339. $(".player-auxiliary-filter-title").hover(function(){
  340. $(this).addClass("hover")
  341. $(this).css({"height":"35px","border-bottom": "2px solid #32AAFF","text-decoration":"none"})
  342. },function(){
  343. $(this).removeClass("hover")
  344. if(!$(this).hasClass("on"))
  345. $(this).css({"height":"35px","border-bottom": "none","text-decoration":"none"})
  346. })
  347.  
  348. $(".bui-collapse-body").on('toggle',function(){
  349. return false;
  350. })
  351.  
  352. $(".player-auxiliary-filter-title:nth-of-type(1)").click(function(){
  353. event.preventDefault()
  354. event.stopPropagation();
  355. return false
  356. })
  357.  
  358. $(".player-auxiliary-filter-title:nth-of-type(2)").click(function(){
  359. event.preventDefault()
  360. event.stopPropagation();
  361. $(".player-auxiliary-filter-title").fadeOut(300)
  362.  
  363. var text = $(this).text()
  364. $(".player-auxiliary-setting-menu-wrap").children().each(function(){
  365. if($(this).text() == text)
  366. $(this).click()
  367. })
  368. $(".player-auxiliary-filter-title").fadeIn(300)
  369. $(".player-auxiliary-setting-menu-wrap").hide()
  370. $(".player-auxiliary-filter-title").removeClass("on")
  371. $(this).parent().children().eq(0).addClass("on")
  372. if($(".bui-collapse-arrow-text").text().indexOf("展开") > -1)
  373. $(".bui-collapse-arrow-text").click()
  374. $("#danmukuBox").attr("style","height: 493px;")
  375. return false
  376. })
  377. $(".player-auxiliary-filter-title:nth-of-type(3)").click(function(){
  378. event.preventDefault()
  379. event.stopPropagation();
  380. $(".player-auxiliary-filter-title").fadeOut(300)
  381. var text = $(this).text()
  382. $(".player-auxiliary-setting-menu-wrap").children().each(function(){
  383. if($(this).text() == text)
  384. $(this).click()
  385. })
  386. $(".player-auxiliary-filter-title").fadeIn(300)
  387. $(".player-auxiliary-setting-menu-wrap").hide()
  388. $(".player-auxiliary-filter-title").removeClass("on")
  389. $(this).parent().children().eq(0).addClass("on")
  390. if($(".bui-collapse-arrow-text").text().indexOf("展开") > -1)
  391. $(".bui-collapse-arrow-text").click()
  392. $("#danmukuBox").attr("style","height: 493px;")
  393. return false;
  394. })
  395. setInterval(function(){
  396.  
  397. if($(".bui-collapse-arrow-text").text().indexOf("收起") > -1)
  398. $("#danmukuBox").attr("style","height: auto;")
  399.  
  400. $(".player-auxiliary-filter").each(function(){
  401.  
  402. if($(this).children().eq(0).text().indexOf("弹幕列表") > -1)
  403. {
  404. if($(this).children().eq(1).text().indexOf("屏蔽设定") == -1)
  405. $(this).children().eq(1).text("屏蔽设定")
  406. if($(this).children().eq(2).text().indexOf("高级弹幕") == -1)
  407. $(this).children().eq(2).text("高级弹幕")
  408. }
  409. else if($(this).children().eq(0).text().indexOf("屏蔽设定") > -1)
  410. {
  411. if($(this).children().eq(1).text().indexOf("弹幕列表") == -1)
  412. $(this).children().eq(1).text("弹幕列表")
  413. if($(this).children().eq(2).text().indexOf("高级弹幕") == -1)
  414. $(this).children().eq(2).text("高级弹幕")
  415. }
  416. else if($(this).children().eq(0).text().indexOf("高级弹幕") > -1)
  417. {
  418. if($(this).children().eq(1).text().indexOf("弹幕列表") == -1)
  419. $(this).children().eq(1).text("弹幕列表")
  420. if($(this).children().eq(2).text().indexOf("屏蔽设定") == -1)
  421. $(this).children().eq(2).text("屏蔽设定")
  422. }
  423.  
  424. })
  425.  
  426. $(".player-auxiliary-filter-title").each(function(){
  427. if($(this).hasClass("on") || $(this).hasClass("hover"))
  428. $(this).css({"border-bottom": "2px solid #32AAFF"})
  429. else
  430. $(this).css({"border-bottom": "none"})
  431. })
  432.  
  433. },10)
  434. clearInterval(t3)
  435. }
  436. },100)
  437.  
  438. setInterval(function(){
  439. $("#bannerAd").remove();
  440. $(".gg-floor-module").hide()
  441. $("#slide_ad").hide()
  442.  
  443. $(".bilibili-player-video-danmaku-setting-left-block-title").attr("style","color:#FF0000; font-weight:bold")
  444.  
  445. var ban ='<img class="ban" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/'+
  446. 'PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzM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0ZGMDAwMCIgcC1pZD0iMjg3MCI+PC9wYXRoPjwvc3ZnPg==">'
  458. var $ban = $(ban)
  459. $ban.css({"position":"absolute", "top":"17px", "left":"18px", "height":"10px", "width":"10px"})
  460. $(".bilibili-player-block-filter-type.disabled").find("svg").after($ban)
  461. },100)
  462.  
  463. }
  464.  
  465.  
  466. (function() {
  467. 'use strict';
  468. var timer = setInterval(function(){
  469. if(window.jQuery)
  470. {
  471. clearInterval(timer)
  472. setTimeout(function(){
  473. v();
  474. },1500)
  475. }
  476. },100)
  477. })();