您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Prints course duration on console
// ==UserScript== // @name Wes Bos Courses Duration // @namespace https://github.com/xaxim/ // @version 0.4 // @description Prints course duration on console // @author xaxim // @match https://javascript30.com/account/access/* // @match https://es6.io/account/access/* // @match https://reactforbeginners.com/account/access/* // @match https://sublimetextbook.com/account/access/* // @match https://flexbox.io/account/access/* // @match https://commandlinepoweruser.com/account/access/* // @match https://learnredux.com/account/access/* // @match https://masteringmarkdown.com/account/access/* // @match https://*/account/access/* // @grant none // ==/UserScript== function getWesDuration(start = 0, end) { const timeNodes = Array.from(document.querySelectorAll('.duration')); const last = end || timeNodes.length; const seconds = timeNodes .filter((node) => { const videoNumber = parseFloat(node.parentNode.parentNode.parentNode.querySelector('.video-number').textContent); return videoNumber >= start && videoNumber <= last; }) .map(node => node.textContent) .map((timeStr) => { const [mins, secs] = timeStr.split(':').map(parseFloat); return (mins * 60) + secs; }) .reduce((total, current) => total + current); const minsPerHour = 60; const secsPerHour = minsPerHour * 60; let secondsLeft = seconds; const hours = Math.floor(secondsLeft / secsPerHour); secondsLeft %= secsPerHour; const minutes = Math.floor(secondsLeft / minsPerHour); secondsLeft %= minsPerHour; /* eslint-disable */ console.log(`Duration of this course: ${hours} hours ${minutes} minutes and ${secondsLeft} seconds`); /* eslint-enable */ } getWesDuration();