5Outils

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

当前为 2018-01-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         5Outils
// @namespace    http://tampermonkey.net/
// @version      3.4
// @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/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) {
        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.social-provider.com/controller/messagesController.php',
            type: 'GET',
            dataType: 'json',
            data: {
               ajax: '1',
               version: '3.4',
               security: APIKEY,
               url: window.location.href
            },
            error: function(retour) {
                erreurAjaxDynamicButtons('Impossible de joindre le serveur Social Provider.');
            },
            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.social-provider.com/controller/orderController.php',
            type: 'GET',
            data: {
               action: 'badge',
               messagesId: messagesId,
               firstLoad: firstLoad,
               security: APIKEY
            },
            success: function(retour) {
                $('body').append(retour);
            },
        });
    }

})();