B站稍后再看跳转

从B站稍后再看页面跳转到视频详情页

  1. // ==UserScript==
  2. // @name B站稍后再看跳转
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 从B站稍后再看页面跳转到视频详情页
  6. // @author shxzz
  7. // @match https://www.bilibili.com/list/watchlater*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 创建跳转按钮
  16. function createRedirectButton() {
  17. const button = document.createElement('div');
  18. button.className = 'fixed-sidenav-storage-item';
  19. button.title = '跳转到视频详情页';
  20. button.innerHTML = `
  21. <svg class="fixed-sidenav-storage-item-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
  22. <path d="M12 4L10.59 5.41L16.17 11H4V13H16.17L10.59 18.59L12 20L20 12L12 4Z" fill="currentColor"/>
  23. </svg>
  24. 详情页
  25. `;
  26. // 创建外层容器
  27. const container = document.createElement('div');
  28. container.className = 'custom-fixed-sidenav';
  29. container.style.cssText = `
  30. position: fixed;
  31. right: 6px;
  32. bottom: 226px;
  33. z-index: 100;
  34. width: 40px;
  35. border-radius: 8px;
  36. background: #fff;
  37. box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  38. `;
  39.  
  40. // 添加按钮样式
  41. button.style.cssText = `
  42. display: flex;
  43. flex-direction: column;
  44. align-items: center;
  45. justify-content: center;
  46. width: 40px;
  47. height: 40px;
  48. padding: 7px 0;
  49. cursor: pointer;
  50. color: #18191c;
  51. font-size: 12px;
  52. line-height: 1.2;
  53. transition: all .2s;
  54. text-align: center;
  55. `;
  56.  
  57. // 添加SVG图标样式
  58. const svg = button.querySelector('svg');
  59. svg.style.cssText = `
  60. margin-bottom: 4px;
  61. `;
  62.  
  63. // 添加hover效果
  64. button.addEventListener('mouseenter', () => {
  65. button.style.color = '#00aeec';
  66. button.style.backgroundColor = 'var(--graph_bg_thin, #f1f2f3)';
  67. });
  68. button.addEventListener('mouseleave', () => {
  69. button.style.color = '';
  70. button.style.backgroundColor = '';
  71. });
  72.  
  73. // 点击事件处理
  74. button.addEventListener('click', redirectToVideoPage);
  75.  
  76. container.appendChild(button);
  77. return container;
  78. }
  79.  
  80. // 跳转到视频详情页
  81. function redirectToVideoPage() {
  82. const currentUrl = window.location.href;
  83. const bvid = new URLSearchParams(currentUrl.split('?')[1]).get('bvid');
  84. if (bvid) {
  85. // 使用相对路径
  86. window.location.href = `/video/${bvid}/`;
  87. }
  88. }
  89.  
  90. // 初始化
  91. function init() {
  92. // 检查是否已存在按钮
  93. if (!document.querySelector('.custom-fixed-sidenav')) {
  94. const button = createRedirectButton();
  95. document.body.appendChild(button);
  96. }
  97. }
  98.  
  99. // 页面加载完成后执行初始化
  100. if (document.readyState === 'loading') {
  101. document.addEventListener('DOMContentLoaded', init);
  102. } else {
  103. init();
  104. }
  105. })();

QingJ © 2025

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