CISM++

Améliorations variées du site Web de CISM

Tính đến 02-11-2014. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         CISM++
// @namespace    http://eepp.ca/
// @version      0.1
// @description  Améliorations variées du site Web de CISM
// @author       Philippe Proulx
// @match        *://cism893.ca/*
// @grant        none
// ==/UserScript==

// sauvegarde de l'initialisation originale de FicheEmission
var ficheEmissionInit = FicheEmission.prototype.initialize;

// nouvelle initialisation de FicheEmission
FicheEmission.prototype.initialize = function() {
    // HH:MM:SS -> nombre de secondes
    function hhmmss2secs(hhmmss) {
        var tokens = hhmmss.split(':');
        var mul = 1;
        var secs = 0;
        
        for (var i = tokens.length - 1; i >= 0; --i) {
            secs += parseInt(tokens[i]) * mul;
            mul *= 60;
        }
        
        return secs;
    }
    
    // étiquettes de temps
    var $times = $('.episodes-list time');
    
    $times.each(function() {
        var $time = $(this);
     
        // changer seulement si ce n'est pas déjà fait
        if (!$time.attr('data-secs')) {
            // attribute "data-secs" contient le nombre de secondes
        	$time.attr('data-secs', hhmmss2secs($time.text()));
            
            // style
            $time.css('color', '#ee393e');
            $time.hover(function() {
                $(this).css('color', '#6d090c');
            }, function() {
                $(this).css('color', '#ee393e');
            });
            
            // action (sauter au bon endroit dans l'audio en cours de lecture)
            $time.click(function(ev) {
                ev.stopPropagation();
                player.seekTo(parseInt($time.attr('data-secs')) / player.duration * 100);
            });
        }
    });
    
    // appeler l'initialisation originale de FicheEmission
    ficheEmissionInit.call(this);
};