您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Click Title to get Youtube current Seconds in clipboard.
当前为
// ==UserScript== // @name Get Youtube current Seconds // @namespace http://tampermonkey.net/ // @version 1.1 // @description Click Title to get Youtube current Seconds in clipboard. // @author fengxxc // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function getSeconds(timestamp) { const sp = timestamp.split(":").map(Number) let seconds = 0 for (let i = 0; i < sp.length; i++) { seconds += sp[i] * (60 ** (sp.length - i - 1)) } return seconds } let btn = null let intervalId = setInterval(() => { if (btn != null) { clearInterval(intervalId) console.log(btn) btn.onclick = () => { const currenttime = document.querySelector('.ytp-time-current').innerText const currentSeconds = getSeconds(currenttime) const url = `${window.location.href}&t=${currentSeconds}s` console.log(`Now Play: ${currenttime}, seconds: ${currentSeconds}, url: ${url}`) navigator.clipboard.writeText(url).then(() => { console.log('url copied to clipboard'); }).catch(err => { console.error('Failed to copy text: ', err); }); } } btn = document.querySelector('#above-the-fold > #title') }, 60) })();