您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Prevents the default action for linked wav/mp3 files. Inplace playback using HTML5 instead.
当前为
// ==UserScript== // @name wav link fix // @namespace gnblizz // @description Prevents the default action for linked wav/mp3 files. Inplace playback using HTML5 instead. // @include * // @version 1 // @grant none // @icon http://japanese.about.com/library/weekly/graphics/speaker.gif // ==/UserScript== // sample page http://japanese.about.com/od/japanesevocabulary/a/expression.htm var i = document.links.length; if(i) do { if(/\.(wav|mp3)$/i.test(document.links[--i].toString())) document.links[i].addEventListener('click', WavFixOnClickHandler); } while(i); function WavFixOnClickHandler(event) { event.preventDefault(); // if(invisible controls){ var node = event.currentTarget, wrp = document.createElement('div'), ref = node.getAttribute('href'), type = ref.slice(-3); switch(type){ case 'mp3': type = 'mpeg'; break; } wrp.setAttribute('style', 'position:absolute;visibility:hidden;'); wrp.innerHTML = '<audio controls autoplay><source src="' + ref + '" type="audio/' + type + '"></audio>'; wrp.firstChild.onended = function() { wrp.parentNode.removeChild(wrp); }; document.body.appendChild(wrp); /* } else { var node = document.getElementById('dynamicAudioControl'); if(node) node.parentNode.removeChild(node); node = event.currentTarget; var wrp = document.createElement('div'), ref = node.getAttribute('href'), type = ref.slice(-3); switch(type){ case 'mp3': type = 'mpeg'; break; } var pos = event.clientX-180; if(pos<0) pos = 0; pos = 'left:' + pos + 'px;top:' + (window.pageYOffset+event.clientY-18) + 'px;'; wrp.setAttribute('style', pos+'position:absolute!important;padding:0px;border:1px solid gray;'); wrp.innerHTML='<audio controls autoplay style="float:left;"><source src="' + ref + '" type="audio/' + type + '"></audio>'; wrp.setAttribute('id', 'dynamicAudioControl'); var btn = document.createElement('input'); btn.type = 'button'; btn.value = 'x'; btn.setAttribute('style', 'display:inline;padding:0px;height:auto;vertical-align:top;') btn.onclick = function() { wrp.parentNode.removeChild(wrp); }; wrp.appendChild(btn); document.body.appendChild(wrp); } */ return false; }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址