【发布时间】:2010-08-30 17:02:40
【问题描述】:
我正在编写我的第一个 GM 脚本,用 HTML 5 音频标签替换 http://www.freesound.org 上的 Flash 预览,并在搜索结果中添加下载链接。我让后者工作正常,但我无法在 Firefox 3.5.9 中显示音频标签。这是我的脚本:
// ==UserScript==
// @name FreeSound HTML 5 Preview
// @namespace http://thewordnerd.info
// @description Replace Flash-based sound previews on freesound.org with audio tags and add quick download links
// @include http://freesound.org/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
// ==/UserScript==
$(document).ready(function() {
$("embed").remove();
$(".samplelist").each(function(index) {
sampleNo = $(this).find("a:first").attr("href").split("?")[1].split("=")[1];
userName = $(this).find("a:eq(1)").html();
title = $(this).find("a:first").html().replace(/ /g, "_");
url = "/download/"+sampleNo+"/"+sampleNo+"_"+userName+"_"+title;
$(this).find("script").replaceWith("<audio src='"+url+"' controls='controls' type='audio/wave'/>");
//$(this).find("audio").removeAttr("tabindex");
$(this).append("<a href='"+url+"'>Download</a>");
});
});
我可以在 Firebug 中看到该元素,看起来还不错。
想到我在这里可能做错了什么?由于下载链接确实下载了请求的文件,因为它是一个波,而且我认为我已经设置了正确的类型,所以我不知道为什么它没有显示。
【问题讨论】:
标签: firefox audio html greasemonkey