Skip to content

Instantly share code, notes, and snippets.

@devurandom
Last active December 14, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devurandom/5150447 to your computer and use it in GitHub Desktop.
Save devurandom/5150447 to your computer and use it in GitHub Desktop.
Google Docs - Audio Preview for MP3/WAV/OGG - WIP
// ==UserScript==
// @name Google Docs - Audio Preview for MP3/WAV/OGG
// @namespace http://leith.caldwell.net.nz/, www.lucianobello.com.ar (original: http://www.manekinekoninja.com)
// @version 1.2.7
// @author Leith Caldwell, Luciano Bello, edited by Tommy Smith, Dennis Schridde simplified it and removed flash usage
// @description Shows a player (google player for MP3 or audio tag for other formats) to preview audio files at Google Docs.
// @include http://docs.google.com/file/d/*/edit*
// @include https://docs.google.com/file/d/*/edit*
// ==/UserScript==
// the guts of this userscript
var filename = document.getElementsByClassName("docs-title-inner")[0].innerHTML;
var audioFile = window.location.protocol + '//docs.google.com/uc?authuser=0&id=' + window.location.pathname.substring(window.location.pathname.indexOf("/file/d/")+8, window.location.pathname.indexOf("/edit")) + '&export=download&confirm=no_antivirus';
var nopreview = document.getElementsByClassName("texmex-nopreview-msg")[0];
var audio = document.createElement("audio");
audio.setAttribute("src", audioFile);
audio.setAttribute("controls", "controls");
audio.innerHTML = "Your browser does not support the audio element.";
nopreview.appendChild(audio);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment