您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
打开视频时默认回到视频开头处
当前为
// ==UserScript== // @name BiliBackToBeginning // @namespace https://github.com/ImQQiaoO/BiliBackToBeginning // @version v0.1.1 // @description 打开视频时默认回到视频开头处 // @author ImQQiaoO // @match *://*.bilibili.com/* // @exclude *://message.bilibili.com/pages/nav/header_sync // @exclude *://message.bilibili.com/pages/nav/index_new_pc_sync // @exclude *://data.bilibili.com/* // @exclude *://cm.bilibili.com/* // @exclude *://link.bilibili.com/* // @exclude *://passport.bilibili.com/* // @exclude *://api.bilibili.com/* // @exclude *://api.*.bilibili.com/* // @exclude *://*.chat.bilibili.com/* // @exclude *://member.bilibili.com/* // @exclude *://www.bilibili.com/tensou/* // @exclude *://www.bilibili.com/correspond/* // @exclude *://live.bilibili.com/p/html/* // @exclude *://live.bilibili.com/live-room-play-game-together // @exclude *://www.bilibili.com/blackboard/comment-detail.html* // @exclude *://www.bilibili.com/blackboard/newplayer.html* // @license MIT // @grant none // Explicitly state no special GM functions needed if true // ==/UserScript== (function() { "use strict"; const STORAGE_KEY = "reset_bili_video_enabled"; function setEnabled(flag) { localStorage.setItem(STORAGE_KEY, flag ? "1" : "0"); } function getEnabled() { return localStorage.getItem(STORAGE_KEY) === "1"; } function createSettingsPanel() { // CSS styles for the settings panel and button const style = ` #biliResetPanel { position: fixed; bottom: 30px; right: 30px; z-index: 99999; background: #fff; color: #333; border: 1px solid #bbb; border-radius: 8px; box-shadow: 0 6px 16px rgba(0,0,0,.1); padding: 18px 26px 18px 18px; font-size: 16px; display: none; } #biliResetPanel input[type=checkbox] { transform: scale(1.3); margin-right: 8px; } #biliResetPanelClose { cursor: pointer; color: #f66; float: right; font-size: 18px; } #biliResetPanelBtn { position: fixed; bottom: 30px; right: 30px; z-index: 99998; background: #ffe2a0; color: #333; border: 1px solid #bbb; border-radius: 50%; width: 42px; height: 42px; text-align: center; line-height: 42px; font-size: 24px; cursor: pointer; box-shadow: 0 3px 12px rgba(0,0,0,.08); } `; const styleEl = document.createElement("style"); styleEl.textContent = style; document.head.appendChild(styleEl); // Settings panel HTML const panel = document.createElement("div"); panel.id = "biliResetPanel"; panel.innerHTML = ` <span id="biliResetPanelClose" title="关闭设置面板">×</span> <label> <input type="checkbox" id="biliResetSwitch"> 启用自动重置进度到0秒 </label> `; document.body.appendChild(panel); // Show/hide settings panel button const btn = document.createElement("div"); btn.id = "biliResetPanelBtn"; btn.title = "打开【重置到0秒】设置"; btn.textContent = "⚙"; document.body.appendChild(btn); btn.onclick = () => { panel.style.display = "block"; }; document.getElementById("biliResetPanelClose").onclick = () => { panel.style.display = "none"; }; document.getElementById('biliResetSwitch').checked = getEnabled(); document.getElementById('biliResetSwitch').onchange = (e) => { setEnabled(e.target.checked); }; } function resetBilibiliVideo() { const video = document.querySelector("video"); if (video && getEnabled()) { if (video.readyState >= 2) { // Check if video metadata is loaded video.currentTime = 0; video.play(); console.log("[B站重置进度脚本] 已直接重置到开头!"); } else { video.addEventListener("loadedmetadata", () => { video.currentTime = 0; video.play(); console.log("[B站重置进度脚本] 已直接重置到开头!"); }, { once: true }); // Use once option to ensure the event listener is removed after first execution } } } function observeVideoLoad() { let lastHref = ""; setInterval(() => { if (location.href !== lastHref) { lastHref = location.href; setTimeout(resetBilibiliVideo, 50); } }, 500); } createSettingsPanel(); observeVideoLoad(); setTimeout(resetBilibiliVideo, 50); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址