Ampache auto skip

Auto-Skip TamperMonkey/GreaseMonkey script for corrupt MP3s

My Ampache web player gets stuck one second before the end of some MP3 tracks because the file headers say that it is one second longer than the stream actually is.

This script runs in the browser and checks to see if there is still one second to go and also that the play button is visible.

This is the case when an MP3 is corrupt for me and so this script just presses the skip button so I can still enjoy my albums without having to look at the player.

Please feel free to make it better and post back the changes so I can improve my own experience, thanks :)

// ==UserScript==
// @name       Ampache Autoskip
// @namespace
// @version    0.1
// @description  Skips the track if Ampache fails to
// @match*
// @copyright  2012+, Tom Gould
// @require
// @grant GM_addStyle
// ==/UserScript==
var skipAmpache = function () {
    var currentTime = jQuery('').html();
    var duration = jQuery('').html();
    if (undefined == currentTime || undefined == duration) {
      setTimeout(skipAmpache, 3000);
    var cur = parseFloat(currentTime.replace(':', ''));
    var dur = parseFloat(duration.replace(':', ''));
    var diff = dur - cur;
    if (diff <= 1 && jQuery('.jp-play').css('display') == 'block') {
        console.log('Skipping: ' + jQuery('.playing_title a').html());;
        setTimeout(skipAmpache, 10000);
    setTimeout(skipAmpache, 1000);


Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.