您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Crea un botón para guardar logs para AJR
// ==UserScript== // @name AJR log Youtube // @namespace http://tampermonkey.net/ // @version 0.2 // @description Crea un botón para guardar logs para AJR // @author Pedrubik 🦙 // @license GPL-3.0-or-later // @match https://www.youtube.com/feed/history // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant GM_setClipboard // @run-at document-start // ==/UserScript== (function() { 'use strict'; function howManyColons(timeString){ let count = (timeString.match(/:/g) || []).length return count } function timeToMinutes(timeString){ let numberOfColons = howManyColons(timeString); let numbersTime = timeString.split(":") if (numberOfColons === 1){ if(numbersTime[1] > 30){ return parseInt(numbersTime[0]) + 1 } else { return parseInt(numbersTime[0]) } } else if (numberOfColons === 2){ if(numbersTime[2] > 30){ return parseInt(numbersTime[0])*60 + parseInt(numbersTime[1]) + 1 } else { return parseInt(numbersTime[0])*60 + parseInt(numbersTime[1]) } } } function progressTime(time, progress){ return Math.round(time*progress/100) } function addButtonAndCopyText(element) { console.log(element) if (!element.querySelector('.copy-button')) { const button = document.createElement('span'); button.innerText = 'Copiar log'; button.className = 'copy-button'; button.style.background = 'transparent'; button.style.border="none"; button.style.color="var(--color-text-lighter)"; button.style.fontWeight=800; button.style.fontSize="1.1rem"; button.style.cursor="pointer"; button.style.fontFamily="Overpass,-apple-system,BlinkMacSystemFont,Segoe UI,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif"; button.style.marginLeft="10px"; element.appendChild(button); button.addEventListener('click', () => { let time = timeToMinutes(element.querySelector("#time-status").innerText) let videoTitle = "https://www.youtube.com" + element.querySelector("#thumbnail").getAttribute("href") const progress = element.querySelector("#progress").getAttribute("style").replace("width:","").replace("%","").replace(";","") time = progressTime(time, progress) videoTitle = videoTitle.replace(/(&t=\d+s)/, ''); GM_setClipboard('.log video '+ time + " " + videoTitle, 'text'); }); } }; function myscript() { console.log("start") let containers = document.querySelectorAll("#dismissible") containers.forEach(addButtonAndCopyText) }; setTimeout(myscript, 4000); })();