您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Changes the ?t= parameter when pausing.
当前为
// ==UserScript== // @name Youtube Resumer // @description Changes the ?t= parameter when pausing. // @version 4 // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // @namespace https://greasyfork.org/users/206408 // ==/UserScript== (async () => { function l(...args){ console.log(`[Youtube Resumer]`, ...args) } function findVideo(){ return document.querySelector('video') } //update ?t= function changeUrl(time){ const url = new URL(window.location.href) url.searchParams.set('t', time) window.history.replaceState(null, null, url) } function listen(){ const video = findVideo() video.addEventListener('pause', () => { changeUrl(parseInt(video.currentTime)) }) } let listening = false //the video element exists even if you go back to the home page, so no need to readd event listeners //Event for each page change document.addEventListener("yt-navigate-finish", function() { l('navigate-finish') //Match page with video if(window.location.href.match(new RegExp('https://www.youtube.com/watch\\?v=.'))) { //Add video listener once if(!listening){ l('listening') listen() listening = true } } }); })();