5Outils

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

  1. // ==UserScript==
  2. // @name 5Outils
  3. // @namespace http://tampermonkey.net/
  4. // @version 3.6.3
  5. // @description Outils complémentaires pour les vendeurs du site 5euros.com. Ce plugin est gratuit :-)
  6. // @author Thomas21
  7. // @match https://5euros.com/dashboard/commande/*
  8. // @match https://5euros.com/dashboard/thread/*
  9. // @match https://5euros.com/message/*
  10. // @match https://5euros.com/commande/*
  11. // @match https://5euros.com/ventes
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. //////////////////////////////
  19. var APIKEY = "VotreCleIci"; // Entrez votre clé API ici, entre les guillemets
  20. //////////////////////////////
  21.  
  22.  
  23. var curPage = "";
  24.  
  25. if (window.location.href.indexOf("thread") > -1 || window.location.href.indexOf("commande") > -1 || window.location.href.indexOf("message") > -1) {
  26. curPage = "conversation";
  27. }
  28. if (window.location.href.indexOf("ventes") > -1) {
  29. curPage = "ventes";
  30. }
  31.  
  32. // Features appliquées aux conversations
  33. if(curPage == "conversation"){
  34. // Conteneur du script Boutons Custom
  35. var PageTargetBlock = $('.trackingControl-Timeline');
  36. if (window.location.href.indexOf("thread") > -1) {
  37. PageTargetBlock = $('.messageSubmit');
  38. }
  39.  
  40. $('body').on('click', '#restartAjax', function(){
  41. $('#restartAjax').parent().hide();
  42. loadDynamicButtons();
  43. });
  44. $(document).ready(function(){
  45. loadDynamicButtons();
  46. });
  47. }
  48.  
  49.  
  50. // Features appliquées au listing des commandes
  51. if(curPage == "ventes"){
  52. var tableauContainer = $('#threads-listing');
  53.  
  54. $(document).ready(function(){
  55. showCustomBadge(true);
  56. });
  57.  
  58. // Override la fonction
  59. var origupdateButtonFilters = window.updateButtonFilters;
  60. window.updateButtonFilters = function(argument) {
  61. origupdateButtonFilters();
  62. showCustomBadge(false);
  63. };
  64.  
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. function loadDynamicButtons(){
  72. $.ajax({
  73. url: 'https://5outils.[domaine caché].com/controller/messagesController.php',
  74. type: 'GET',
  75. dataType: 'json',
  76. data: {
  77. ajax: '1',
  78. version: '3.6.2',
  79. security: APIKEY,
  80. url: window.location.href
  81. },
  82. error: function(retour) {
  83. erreurAjaxDynamicButtons('Impossible de joindre le serveur.');
  84. },
  85. success: function(retour) {
  86. if(retour.status){
  87. PageTargetBlock.prepend(retour.content);
  88. }
  89. else {
  90. erreurAjaxDynamicButtons(retour.content);
  91. }
  92. },
  93. });
  94. }
  95.  
  96. function erreurAjaxDynamicButtons(messageErreur){
  97. 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>');
  98. }
  99.  
  100.  
  101. function showCustomBadge(firstLoad){
  102. var messagesId = [];
  103. $('table.table tbody tr').each(function(){
  104. messagesId.push(($(this).attr("data-id")));
  105. });
  106. console.log("showCustomBadge() firstLoad: "+firstLoad);
  107.  
  108. $.ajax({
  109. url: 'https://5outils.[domaine caché].com/controller/orderController.php',
  110. type: 'GET',
  111. data: {
  112. action: 'badge',
  113. messagesId: messagesId,
  114. firstLoad: firstLoad,
  115. security: APIKEY
  116. },
  117. success: function(retour) {
  118. $('body').append(retour);
  119. },
  120. });
  121. }
  122.  
  123. })();