5Outils

Outils complémentaires pour les vendeurs du site 5euros.com. Ce plugin est gratuit :-)

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 لتثبيت هذا النمط.

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

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

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

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

// ==UserScript==
// @name         5Outils
// @namespace    http://tampermonkey.net/
// @version      3.6.3
// @description  Outils complémentaires pour les vendeurs du site 5euros.com. Ce plugin est gratuit :-)
// @author       Thomas21
// @match        https://5euros.com/dashboard/commande/*
// @match        https://5euros.com/dashboard/thread/*
// @match        https://5euros.com/message/*
// @match        https://5euros.com/commande/*
// @match        https://5euros.com/ventes
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    //////////////////////////////
    var APIKEY = "VotreCleIci"; // Entrez votre clé API ici, entre les guillemets
    //////////////////////////////


    var curPage = "";

    if (window.location.href.indexOf("thread") > -1 || window.location.href.indexOf("commande") > -1 || window.location.href.indexOf("message") > -1) {
        curPage = "conversation";
    }
    if (window.location.href.indexOf("ventes") > -1) {
        curPage = "ventes";
    }

    // Features appliquées aux conversations
    if(curPage == "conversation"){
        // Conteneur du script Boutons Custom
        var PageTargetBlock = $('.trackingControl-Timeline');
        if (window.location.href.indexOf("thread") > -1) {
            PageTargetBlock = $('.messageSubmit');
        }

        $('body').on('click', '#restartAjax', function(){
            $('#restartAjax').parent().hide();
            loadDynamicButtons();
        });
        $(document).ready(function(){
            loadDynamicButtons();
        });
    }


    // Features appliquées au listing des commandes
    if(curPage == "ventes"){
        var tableauContainer = $('#threads-listing');

        $(document).ready(function(){
            showCustomBadge(true);
        });

        // Override la fonction
        var origupdateButtonFilters = window.updateButtonFilters;
        window.updateButtonFilters = function(argument) {
                origupdateButtonFilters();
                showCustomBadge(false);
        };

    }





    function loadDynamicButtons(){
        $.ajax({
            url: 'https://5outils.[domaine caché].com/controller/messagesController.php',
            type: 'GET',
            dataType: 'json',
            data: {
               ajax: '1',
               version: '3.6.2',
               security: APIKEY,
               url: window.location.href
            },
            error: function(retour) {
                erreurAjaxDynamicButtons('Impossible de joindre le serveur.');
            },
            success: function(retour) {
                if(retour.status){
                    PageTargetBlock.prepend(retour.content);
                }
                else {
                    erreurAjaxDynamicButtons(retour.content);
                }
            },
        });
    }

    function erreurAjaxDynamicButtons(messageErreur){
        PageTargetBlock.prepend('<div class="alert-danger"><b>Impossible de charger les boutons dynamiques :</b> '+messageErreur+' <button id="restartAjax" class="btn btn-small btn-default">Recommencer</button></div>');
    }


    function showCustomBadge(firstLoad){
        var messagesId = [];
        $('table.table tbody tr').each(function(){
            messagesId.push(($(this).attr("data-id")));
        });
        console.log("showCustomBadge() firstLoad: "+firstLoad);

        $.ajax({
            url: 'https://5outils.[domaine caché].com/controller/orderController.php',
            type: 'GET',
            data: {
               action: 'badge',
               messagesId: messagesId,
               firstLoad: firstLoad,
               security: APIKEY
            },
            success: function(retour) {
                $('body').append(retour);
            },
        });
    }

})();