您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Converts audio link on LibriVox page to an audio element loader.
当前为
// ==UserScript== // @name LibriVox PlayMaker // @namespace https://vox.quartertone.net/ // @version 1.2 // @description Converts audio link on LibriVox page to an audio element loader. // @author Quartertone // @icon https://icons.duckduckgo.com/ip2/github.com.ico // @grant none // @match *://librivox.org/* // @exclude *://librivox.org/search* // @exclude *://librivox.org/reader* // @exclude *://librivox.org/ // @license gpl-3.0 // ==/UserScript== (function() { 'use strict'; var btns = document.getElementsByClassName("play-btn"); if (btns.length > 0) { var style = document.createElement("style"); style.innerHTML = "audio{width:110px;height:2em;position:absolute;} audio:hover{width:25em;} .play-btn{cursor:pointer;display:inline;background:transparent;}"; document.head.appendChild(style); var btnum = 0; var previousaudio = null; var lastplayed = "PM_Track"; for (const btn of btns) { btn.title = btn.href; btn.removeAttribute("href"); btn.innerHTML = "load"; btn.nexttrack = btns[++btnum]; btn.tracknum = btnum; btn.parentElement.style.width = "130px"; btn.onclick = function () { let audio = document.createElement("audio"); audio.controls = true; audio.autoplay = true; audio.innerHTML = `<source src="${btn.title}" type="audio/mpeg"/>`; audio.oncanplay = function () { //console.log("button number", btnum); //console.log("audio is ready"); // audio.currentTime = 23; audio.currentTime = getCookie(btn.title) ? getCookie(btn.title) : 0; if (previousaudio != null) previousaudio.pause(); previousaudio = audio; audio.oncanplay = null; }; audio.onplay = function () { //console.log("on playyyy"); createCookie(lastplayed, btn.title); }; audio.ontimeupdate = audio.onpause = function () { createCookie(btn.title, this.currentTime); }; audio.onended = function () { createCookie(btn.title, 0); btn.innerHTML = "played"; if (btn.nexttrack != undefined) { // there is a track after this one btn.nexttrack.click(); } else { // end of album previousaudio = null; createCookie(lastplayed, ""); } }; btn.innerHTML = ""; btn.appendChild(audio); }; } if (getCookie(lastplayed)) { //console.log("lastplayed", getCookie(lastplayed)); document.querySelector("[title='" + getCookie(lastplayed) + "']").click(); } function createCookie(name, value) { window.localStorage.setItem(name, value); } function getCookie(name) { return window.localStorage.getItem(name); } } })();