route.user.js

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

اعتبارا من 12-08-2014. شاهد أحدث إصدار.

لا ينبغي أن لا يتم تثبيت هذا السكريت مباشرة. هو مكتبة لسكبتات لتشمل مع التوجيه الفوقية // @require https://update.greasyfork.org/scripts/4096/13109/routeuserjs.js

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.

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

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

/**
 *  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;
    };
}