route.user.js

Exalea - Route générique pour le P.D.O.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/4096/13109/routeuserjs.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

/**
 *  Prototype d'une route générique
 *
 *  @author Exalea
 */
{
    /**
     *  Constructeur
     *
     *  @param {string} regex Expression régulière permettant de déterminer si le callback doit s'appliquer à la page/URL courante
     *  @param {function} callback Méthode de callback contenant les modifications à effectuer
     *  @returns {Route} this Instance courante (permet l'utilisation de méthodes chaînées)
     *  @constructor
     *
     *  @author Exalea
     */
    var Route = function(regex, callback) {
        this.regex = regex;
        this.callback = callback;
        return this;
    };

    /**
     *  Méthode d'application/test d'une route à une URL donnée
     *
     *  @param {string} url URL à tester
     *  @returns {boolean} true si l'URL passée en paramètre correspond à cette route, false sinon
     *
     *  @author Exalea
     */
    Route.prototype.apply = function(url) {
        if(new RegExp(this.regex).test(url)) {
            this.callback();
            return true;
        }
        return false;
    };
}