Fluffy_Stick_JV

Utiliser les stickers intégrés JVC (L'animation des stickers a été retiré par JVC).

目前为 2024-10-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         Fluffy_Stick_JV
// @author       ImThatGuy_edit_New_Atlantis
// @description  Utiliser les stickers intégrés JVC (L'animation des stickers a été retiré par JVC).
// @namespace    Fluffy_Stick_JV
// @match        *://www.jeuxvideo.com/messages-prives/nouveau.php*
// @match        *://www.jeuxvideo.com/messages-prives/message.php*
// @match        *://www.jeuxvideo.com/forums/42-*
// @match        *://www.jeuxvideo.com/forums/1-*
// @match        *://www.jeuxvideo.com/forums/0-*
// @match        *://www.jeuxvideo.com/recherche/forums/0-*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/tipso/1.0.8/tipso.min.js
// @grant        GM_addStyle
// @version      0.4.3.v230
// @icon         https://image.jeuxvideo.com/stickers/p/1jnh
// @license      MIT
// ==/UserScript==

/*
StickersJVC.
Code de base par ImThatGuy (2018-2020)

*/

/*
Le Script est en 2 parties => 
la 1er : Dependance importé à la MAIN car ça bug en importation classique (1_Dependance__jquery__MIT_License)
La 2eme LE SCRIPT LUI MEME (2_Script_Stickers_Script)

Pour voir le script aller à => 2_Script_Stickers_Script

*/

//1_Dependance__jquery__MIT_License_____________

//https://raw.githubusercontent.com/avxto/nuContextMenu/master/src/jquery.nu-context-menu.js

/**
 * nuContextMenu - jQuery Plugin
 * Copyright (c) 2015, Alex Suyun
 * Copyrights licensed under The MIT License (MIT)
 */

;
(function($, window, document, undefined) {

  'use strict';

  var plugin = 'nuContextMenu';

  var defaults = {
    hideAfterClick: false,
    contextMenuClass: 'nu-context-menu',
    activeClass: 'active'
  };

  var nuContextMenu = function(container, options) {
    this.container = $(container);
    this.options = $.extend({}, defaults, options);
    this._defaults = defaults;
    this._name = plugin;
    this.init();
  };

  $.extend(nuContextMenu.prototype, {
    init: function() {

      if (this.options.items) {
        this.items = $(this.options.items);
      }

      if (this._buildContextMenu()) {
        this._bindEvents();
        this._menuVisible = this._menu.hasClass(this.options.activeClass);
      }
    },

    _getCallback: function() {
      return ((this.options.callback && typeof this.options.callback ===
      'function') ? this.options.callback : function() {});
    },

    _buildContextMenu: function() {

      // Create context menu
      this._menu = $('<div>')
      .addClass(this.options.contextMenuClass)
      .append('<ul>');

      var menuArray = this.options.menu,
      menuList = this._menu.children('ul');

      // Create menu items
      $.each(menuArray, function(index, element) {

        var item;

        if (element !== null && typeof element !==
          'object') {
          return;
          }

          if (element.name === 'void') {
            item = $('<hr>');
            menuList.append(item);
            return;
          }

          item = $('<li>')
          .attr('data-key', element.name)
          .text(' ' + element.title);

          if (element.icon) {
            var icon = $('<i>')
            .addClass('fa fa-' + element.icon.toString());
            item.prepend(icon);
          }

          menuList.append(item);

      });

      $('body')
      .append(this._menu);

      return true;

    },

    _pDefault: function(event) {
      event.preventDefault();
      event.stopPropagation();
      return false;
    },

    _contextMenu: function(event) {

      event.preventDefault();

      // Store the value of this
      // So it can be used in the listItem click event
      var _this = this;
      var element = event.target;

      if (this._menuVisible || this.options.disable) {
        return false;
      }

      var callback = this._getCallback();
      var listItems = this._menu.children('ul')
      .children('li');

      listItems.off()
      .on('click', function() {

        var key = $(this)
        .attr('data-key');
        callback(key, element);
        if (_this.options.hideAfterClick) {
          _this.closeMenu();
        }
      });

      this.openMenu();
      this._menu.css({
        'top': event.pageY + 'px',
        'left': event.pageX + 'px'
      });

      return true;
    },

    _onMouseDown: function(event) {
      // Remove menu if clicked outside
      if (!$(event.target)
        .parents('.' + this.options.contextMenuClass)
        .length) {
        this.closeMenu();
        }
    },

    _bindEvents: function() {

      if (this.items) {
        // Make it possible to bind to dynamically created items
        this.container.on('contextmenu', this.options.items,
                          $.proxy(this._contextMenu,
                                  this));
      } else {
        this.container.on('contextmenu', $.proxy(this._contextMenu,
                                                 this));
      }

      // Remove menu on click
      $(document)
      .on('mousedown', $.proxy(this._onMouseDown, this));

    },

    disable: function() {
      this.options.disable = true;
      return true;
    },

    destroy: function() {
      if (this.items) {
        this.container.off('contextmenu', this.options.items);
      } else {
        this.container.off('contextmenu');
      }
      this._menu.remove();
      return true;
    },

    openMenu: function() {
      this._menu.addClass(this.options.activeClass);
      this._menuVisible = true;
      return true;
    },

    closeMenu: function() {
      this._menu.removeClass(this.options.activeClass);
      this._menuVisible = false;
      return true;
    }

  });

  $.fn[plugin] = function(options) {
    var args = Array.prototype.slice.call(arguments, 1);

    return this.each(function() {
      var item = $(this),
                     instance = item.data(plugin);
                     if (!instance) {
                       item.data(plugin, new nuContextMenu(this, options));
                     } else {
                       if (typeof options === 'string' && options[0] !== '_' &&
                         options !== 'init') {
                         instance[options].apply(instance, args);
                         }
                     }
    });
  };

})(jQuery, window, document);


// Texte de la licence MIT
/*
MIT License

Copyright (c) 2015, Alex Suyun

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/



//2_Script_Stickers_Script_______

/*jshint multistr: true */
(function() {
    'use strict';

    // IMPORT CSS
    $('head').append('<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tipso/1.0.8/tipso.min.css"/>');

    // Current div
    var currentDiv = localStorage.getItem('currentDiv');
    //valeur_a_check
    const valeursachecker = ['hap', 'noel', 'autres', 'brid', 'rex', 'fluffy', 'grukklama', 'bud', 'euro', 'larspon'];
    currentDiv = valeursachecker.includes(currentDiv) ? currentDiv : 'brid';
    // LISTS
    var _stickers_hap = [
        "https://image.jeuxvideo.com/stickers/p/1kki",
        "https://image.jeuxvideo.com/stickers/p/1kkn",
        "https://image.jeuxvideo.com/stickers/p/1lmk",
        "https://image.jeuxvideo.com/stickers/p/1kkl",
        "https://image.jeuxvideo.com/stickers/p/1lmh",
        "https://image.jeuxvideo.com/stickers/p/1ljr",
        "https://image.jeuxvideo.com/stickers/p/1kkh",
        "https://image.jeuxvideo.com/stickers/p/1kkk",
        "https://image.jeuxvideo.com/stickers/p/1lmn",
        "https://image.jeuxvideo.com/stickers/p/1ljm",
        "https://image.jeuxvideo.com/stickers/p/1ljl",
        "https://image.jeuxvideo.com/stickers/p/1kkm",
        "https://image.jeuxvideo.com/stickers/p/1rzw",
        "https://image.jeuxvideo.com/stickers/p/1kkj",
        "https://image.jeuxvideo.com/stickers/p/1kkg",
        "https://image.jeuxvideo.com/stickers/p/1ljq"
    ];
    var _stickers_noel = [
        "https://image.jeuxvideo.com/stickers/p/1kkr",
        "https://image.jeuxvideo.com/stickers/p/1kko",
        "https://image.jeuxvideo.com/stickers/p/1kkp",
        "https://image.jeuxvideo.com/stickers/p/1ljj",
        "https://image.jeuxvideo.com/stickers/p/1ljn",
        "https://image.jeuxvideo.com/stickers/p/1kkq",
        "https://image.jeuxvideo.com/stickers/p/1kks",
        "https://image.jeuxvideo.com/stickers/p/1ljo",
        "https://image.jeuxvideo.com/stickers/p/1ljp",
        "https://image.jeuxvideo.com/stickers/p/1kkt",
        "https://image.jeuxvideo.com/stickers/p/1lmm",
        "https://image.jeuxvideo.com/stickers/p/1kku",
        "https://image.jeuxvideo.com/stickers/p/1kkv",
        "https://image.jeuxvideo.com/stickers/p/1mqw",
        "https://image.jeuxvideo.com/stickers/p/1rzs",
        "https://image.jeuxvideo.com/stickers/p/1mqz",
        "https://image.jeuxvideo.com/stickers/p/1nu9",
        "https://image.jeuxvideo.com/stickers/p/1kkg"
    ];
    var _stickers_autres = [
        "https://image.jeuxvideo.com/stickers/p/1lmj",
        "https://image.jeuxvideo.com/stickers/p/1nua",
        "https://image.jeuxvideo.com/stickers/p/1nub",
        "https://image.jeuxvideo.com/stickers/p/1mqv",
        "https://image.jeuxvideo.com/stickers/p/1nu7",
        "https://image.jeuxvideo.com/stickers/p/1lmi",
        "https://image.jeuxvideo.com/stickers/p/1lml",
        "https://image.jeuxvideo.com/stickers/p/1lmo",
        "https://image.jeuxvideo.com/stickers/p/1lmp",
        "https://image.jeuxvideo.com/stickers/p/1mqx",
        "https://image.jeuxvideo.com/stickers/p/1mqy",
        "https://image.jeuxvideo.com/stickers/p/1mr0",
        "https://image.jeuxvideo.com/stickers/p/1mr1",
        "https://image.jeuxvideo.com/stickers/p/1nu6",
        "https://image.jeuxvideo.com/stickers/p/1nu8"
    ];
    var _stickers_brid = [
        "https://image.jeuxvideo.com/stickers/p/1jnd",
        "https://image.jeuxvideo.com/stickers/p/1jnc",
        "https://image.jeuxvideo.com/stickers/p/1jne",
        "https://image.jeuxvideo.com/stickers/p/1jnf",
        "https://image.jeuxvideo.com/stickers/p/1jng",
        "https://image.jeuxvideo.com/stickers/p/1jnh",
        "https://image.jeuxvideo.com/stickers/p/1jni",
        "https://image.jeuxvideo.com/stickers/p/1jnj"
    ];
    var _stickers_rex = [
        "https://image.jeuxvideo.com/stickers/p/1lm9",
        "https://image.jeuxvideo.com/stickers/p/1lma",
        "https://image.jeuxvideo.com/stickers/p/1lmb",
        "https://image.jeuxvideo.com/stickers/p/1lmc",
        "https://image.jeuxvideo.com/stickers/p/1lmd",
        "https://image.jeuxvideo.com/stickers/p/1lme",
        "https://image.jeuxvideo.com/stickers/p/1lmf",
        "https://image.jeuxvideo.com/stickers/p/1lmg"
    ];
    var _stickers_fluffy = [
        "https://image.jeuxvideo.com/stickers/p/1kl8",
        "https://image.jeuxvideo.com/stickers/p/1klb",
        "https://image.jeuxvideo.com/stickers/p/1kl9",
        "https://image.jeuxvideo.com/stickers/p/1kl7",
        "https://image.jeuxvideo.com/stickers/p/1kl5",
        "https://image.jeuxvideo.com/stickers/p/1kl6",
        "https://image.jeuxvideo.com/stickers/p/1kl2",
        "https://image.jeuxvideo.com/stickers/p/1kl1",
        "https://image.jeuxvideo.com/stickers/p/1kl3",
        "https://image.jeuxvideo.com/stickers/p/1kky",
        "https://image.jeuxvideo.com/stickers/p/1kkz",
        "https://image.jeuxvideo.com/stickers/p/1kl4",
        "https://image.jeuxvideo.com/stickers/p/1kl0",
        "https://image.jeuxvideo.com/stickers/p/1kla"
    ];
    var _stickers_grukklama = [
        "https://image.jeuxvideo.com/stickers/p/1lgg",
        "https://image.jeuxvideo.com/stickers/p/1lgb",
        "https://image.jeuxvideo.com/stickers/p/1lga",
        "https://image.jeuxvideo.com/stickers/p/1lgc",
        "https://image.jeuxvideo.com/stickers/p/1lgd",
        "https://image.jeuxvideo.com/stickers/p/1lge",
        "https://image.jeuxvideo.com/stickers/p/1lgf",
        "https://image.jeuxvideo.com/stickers/p/1lgh",
        "https://image.jeuxvideo.com/stickers/p/1kgx",
        "https://image.jeuxvideo.com/stickers/p/1kgv",
        "https://image.jeuxvideo.com/stickers/p/1kgw",
        "https://image.jeuxvideo.com/stickers/p/1kgy",
        "https://image.jeuxvideo.com/stickers/p/1kgu",
        "https://image.jeuxvideo.com/stickers/p/1kh0",
        "https://image.jeuxvideo.com/stickers/p/1kh1",
        "https://image.jeuxvideo.com/stickers/p/1kgz"
    ];
    var _stickers_bud = [
        "https://image.jeuxvideo.com/stickers/p/zuc",
        "https://image.jeuxvideo.com/stickers/p/zu2",
        "https://image.jeuxvideo.com/stickers/p/zu6",
        "https://image.jeuxvideo.com/stickers/p/zu7",
        "https://image.jeuxvideo.com/stickers/p/zu8",
        "https://image.jeuxvideo.com/stickers/p/zu9",
        "https://image.jeuxvideo.com/stickers/p/zua",
        "https://image.jeuxvideo.com/stickers/p/zub",
        "https://image.jeuxvideo.com/stickers/p/1f88",
        "https://image.jeuxvideo.com/stickers/p/1f89",
        "https://image.jeuxvideo.com/stickers/p/1f8a",
        "https://image.jeuxvideo.com/stickers/p/1f8b",
        "https://image.jeuxvideo.com/stickers/p/1f8d",
        "https://image.jeuxvideo.com/stickers/p/1f8e",
        "https://image.jeuxvideo.com/stickers/p/1f8f"
    ];
    var _stickers_euro = [
        "https://image.jeuxvideo.com/stickers/p/1n1m",
        "https://image.jeuxvideo.com/stickers/p/1n1n",
        "https://image.jeuxvideo.com/stickers/p/1n1t",
        "https://image.jeuxvideo.com/stickers/p/1n1q",
        "https://image.jeuxvideo.com/stickers/p/1n1s",
        "https://image.jeuxvideo.com/stickers/p/1n1o"
    ];
    var _stickers_larspon = [
        "https://image.jeuxvideo.com/stickers/p/1lt9",
        "https://image.jeuxvideo.com/stickers/p/1lte",
        "https://image.jeuxvideo.com/stickers/p/1ltd",
        "https://image.jeuxvideo.com/stickers/p/1li4",
        "https://image.jeuxvideo.com/stickers/p/1jc3-fr",
        "https://image.jeuxvideo.com/stickers/p/1li5",
        "https://image.jeuxvideo.com/stickers/p/1n2d",
        "https://image.jeuxvideo.com/stickers/p/1n2i",
        "https://image.jeuxvideo.com/stickers/p/1n2j",
        "https://image.jeuxvideo.com/stickers/p/1n2m"
    ];


    var _stickers_fav = [];


    // FUNCTIONS
    function getCode(element) {
        return element.attr("src").split('/')[5];
    }


    function idTextarea() {
        if (window.location.href.indexOf("jeuxvideo.com/messages-prives/") > -1) {
            return "#message";
        } else {
            return "#message_topic";
        }
    }

    // MAIN APPEND
    var newStickers = '<div style="position: relative">\
                        <div id="fav" class="new-stickers"></div>\
                        <div id="hap" class="new-stickers"></div>\
                        <div id="noel" class="new-stickers"></div>\
                        <div id="autres" class="new-stickers"></div>\
                        <div id="brid" class="new-stickers"></div>\
                        <div id="rex" class="new-stickers"></div>\
                        <div id="fluffy" class="new-stickers"></div>\
                        <div id="grukklama" class="new-stickers"></div>\
                        <div id="bud" class="new-stickers"></div>\
                        <div id="euro" class="new-stickers"></div>\
                        <div id="larspon" class="new-stickers"></div>\
                      </div>';
    $(newStickers).insertAfter('.jv-editor-toolbar');



    // HIDES
    $(".new-stickers").each(function() {
        if ( $(this).attr("id") != currentDiv ) {
            $(this).hide();
        }
    });

    // APPENDS
    let toolbar = document.querySelector(".jv-editor-toolbar")
    let imgBtnGroup = toolbar.querySelectorAll(".btn-group")[2]
    //btns = imgBtnGroup.querySelectorAll("button")
    let stickersBtn = document.createElement("button")
    stickersBtn.classList.add("btn")
    stickersBtn.classList.add("btn-jv-editor-toolbar")
    stickersBtn.setAttribute("id", "old-stickjvc")
    if (window.location.href.indexOf("jeuxvideo.com/messages-prives/") > -1) {
        //MP
    } else {
        stickersBtn.setAttribute("title", "Stickers intégrés")
    }
    stickersBtn.setAttribute("type", "button")
    stickersBtn.innerHTML = "s"
    if (window.location.href.indexOf("jeuxvideo.com/messages-prives/") > -1) {
        stickersBtn.style.textDecoration = "line-through";
        stickersBtn.style.textDecorationThickness = "2px";
    } else {
        //Forum
    }
    stickersBtn.style.lineHeight = "0"
    imgBtnGroup.appendChild(stickersBtn)
    $(".new-stickers").append('<div code="hap" id="hap-css" title="Hap" class="cat-stickers"></div>\
                               <div code="noel" id="noel-css" title="Noel" class="cat-stickers"></div>\
                               <div code="autres" id="autres-css" title="Autres" class="cat-stickers"></div>\
                               <div code="brid" id="brid-css" title="Bridgely" class="cat-stickers"></div>\
                               <div code="rex" id="rex-css" title="Rex ryder" class="cat-stickers"></div>\
                               <div code="fluffy" id="fluffy-css" title="Fluffy" class="cat-stickers"></div>\
                               <div code="grukklama" id="grukklama-css" title="Grukk & Lama" class="cat-stickers"></div>\
                               <div code="bud" id="bud-css" title="Bud" class="cat-stickers"></div>\
                               <div code="euro" id="euro-css" title="Euro" class="cat-stickers"></div>\
                               <div code="larspon" id="larspon-css" title="Larry & Sponsos" class="cat-stickers"></div>');

    // AJOUT STICKERS
    for (var i = 0; i < _stickers_hap.length; i++) {
        $(".new-stickers#hap").append( '<img src="'+_stickers_hap[i]+'" class="stickers-script">' );
    }
    for (var k = 0; k < _stickers_noel.length; k++) {
        $(".new-stickers#noel").append( '<img src="'+_stickers_noel[k]+'" class="stickers-script">' );
    }
    for (var lz = 0; lz < _stickers_autres.length; lz++) {
        $(".new-stickers#autres").append( '<img src="'+_stickers_autres[lz]+'" class="stickers-script">' );
    }
    for (var n = 0; n < _stickers_brid.length; n++) {
        $(".new-stickers#brid").append( '<img src="'+_stickers_brid[n]+'" class="stickers-script">' );
    }
    for (var j = 0; j < _stickers_rex.length; j++) {
        $(".new-stickers#rex").append( '<img src="'+_stickers_rex[j]+'" class="stickers-script">' );
    }
    for (var fff = 0; fff < _stickers_fluffy.length; fff++) {
        $(".new-stickers#fluffy").append( '<img src="'+_stickers_fluffy[fff]+'" class="stickers-script">' );
    }
    for (var gr = 0; gr < _stickers_grukklama.length; gr++) {
        $(".new-stickers#grukklama").append( '<img src="'+_stickers_grukklama[gr]+'" class="stickers-script">' );
    }
    for (var bd = 0; bd < _stickers_bud.length; bd++) {
        $(".new-stickers#bud").append( '<img src="'+_stickers_bud[bd]+'" class="stickers-script">' );
    }
    for (var euo = 0; euo < _stickers_euro.length; euo++) {
        $(".new-stickers#euro").append( '<img src="'+_stickers_euro[euo]+'" class="stickers-script">' );
    }
    for (var lx = 0; lx < _stickers_larspon.length; lx++) {
        $(".new-stickers#larspon").append( '<img src="'+_stickers_larspon[lx]+'" class="stickers-script">' );
    }
    for (var fv = 0; fv < _stickers_fav.length; fv++) {
        $(".new-stickers#fav").append( '<img src="'+_stickers_fav[fv]+'" class="stickers-script sticker-fav">' );
    }


    // Context menu
    var context = $('.new-stickers').nuContextMenu({

        hideAfterClick: true,

        items: '.stickers-script.sticker-fav',

        callback: function(key, element) {
            if ( key == 'del' ) {
                $(element).remove();
                var index = _stickers_fav.indexOf( $(element).attr("src") );
                if (index > -1) {
                    _stickers_fav.splice(index, 1);
                    if (_stickers_fav.length < 1) {
                        $("#fav").append('<p id="aucunFav">Vous n\'avez aucun sticker dans vos favoris.</p>');
                    }
                }
            }
        },

        menu: [
        ]

    });

    var context2 = $('body').nuContextMenu({

        hideAfterClick: true,

        items: '.stickers-script:not(.sticker-fav)',

        callback: function(key, element) {
            if ( key == 'add' ) {
                var n = $(element).attr("src");
                if (_stickers_fav.indexOf(n) > -1) {
                    // Le sticker est déjà en fav
                } else {
                    if ($("#aucunFav").length > 0) { $("#aucunFav").remove(); }
                    $("#fav").append('<img src="'+n+'" class="stickers-script sticker-fav">');
                    $(".stickers-script").off("click"); // Destroy click event stickers
                    stickersEvent();
                    _stickers_fav.push(n);
                    // Store fav
                }
            }
        },

        menu: [

        ]

    });

    // LISTENERS
    function stickersEvent() {
        $(".stickers-script").click(function() {
            // Get sticker code
            var code = getCode( $(this) );
            //$("#message_topic").val($("#message_topic").val() + " [[sticker:p/"+code+"]]");
            var $textarea = jQuery(idTextarea());
            var caretPos = $textarea[0].selectionStart;
            var textAreaTxt = $textarea.val();

            var sticker = "[[sticker:p/"+code+"]] ";

            $textarea.val(textAreaTxt.substring(0, caretPos) + sticker + textAreaTxt.substring(caretPos) );
            $textarea.focus();
        });
    }
    stickersEvent();

    $(".cat-stickers").click(function() {
        var id = $(this).attr("code");
        // Sauvegarde du choix dans le localStorage
        localStorage.setItem('currentDiv', id);
        $(".new-stickers").each(function() {
            if ( $(this).attr("id") == id ) {
                $(this).show();
                if (currentDiv != id) {
                    $("#"+currentDiv).hide();
                    currentDiv = id;
                }
            }
        });
    });

    // NICE SCROLL
    var lastScrollTop = 0;
    var ft_up         = false;
    var ft_down       = false;
    $(".new-stickers").scroll(function() {
        //console.log($(this).scrollTop());
        var st = $(this).scrollTop();
        //console.log(st);
        if (st > lastScrollTop) {
            if (!ft_up) {
                if (st < 50) {
                    ft_up = true;
                    $(this).scrollTop(50);
                }
            }
        } else {
            if (!ft_down) {
                if (st > 50) {
                    ft_down = true;
                    $(this).scrollTop(50);
                }
            }
        }
        lastScrollTop = st;

        // Taille div
        if ($(this).scrollTop() != 0) { // Pas en haut de la div
            $(".cat-stickers").hide(55);
        } else {
             // En haut de la div
            $(".cat-stickers").show(55);
            ft_up   = false;
            ft_down = false;
        }
        if ( $(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight ) {
            // En bas de la div
            ft_up   = false;
            ft_down = false;
        }
    });

    // Active script
    $(".new-stickers#"+currentDiv).hide(0);
    $("#old-stickjvc").click(function() {
        if ( $(".new-stickers").is(":visible") ) {
            $(this).removeClass("active");
            $(".new-stickers#"+currentDiv).hide(80);
        } else {
            $(this).addClass("active");
            $(".new-stickers#"+currentDiv).show(80);
            $(".new-stickers").css("overflow", "auto");
        }
    });

    // TOOLTIPS
    $(document).ready(function() {
        $(".cat-stickers").each(function() {
            $(this).tipso({
                delay: 0,
                speed: 120,
                background: "rgba(0, 0, 0, 0.7)",
                size: 'tiny',
                content: '<b>'+$(this).attr("title")+'</b>',
                width: null,
                maxWidth: "150px"
            });
        });
    });

    // CSS
    //GM_addStyle(".new-stickers:hover { background-color: #f9f9f9; }");
    // Scrollbar
    if (!$.browser.mozilla) {
        GM_addStyle(".new-stickers::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.2); background-color: #f7f7f7; }\
                     .new-stickers::-webkit-scrollbar { width: 9px; background-color: #F5F5F5; }\
                     .new-stickers::-webkit-scrollbar-thumb { background-color: #ccc; }");
    }

    GM_addStyle(".stickers-script { height: 50px; width: 50px; cursor: pointer; padding: 2px; }");

    GM_addStyle(".cat-stickers:hover { border: none; ");
    GM_addStyle(".cat-stickers#hap-css { left: 5px; background-image: url('https://image.jeuxvideo.com/stickers/p/1kki'); }\
                 .cat-stickers#noel-css { left: 30px; background-image: url('https://image.jeuxvideo.com/stickers/p/1kkr'); }\
                 .cat-stickers#autres-css { left: 55px; background-image: url('https://image.jeuxvideo.com/stickers/p/1mqv'); }\
                 .cat-stickers#brid-css { left: 80px; background-image: url('https://image.jeuxvideo.com/stickers/p/1jnh'); }\
                 .cat-stickers#rex-css { left: 105px; background-image: url('https://image.jeuxvideo.com/stickers/p/1lme'); }\
                 .cat-stickers#fluffy-css { left: 130px; background-image: url('https://image.jeuxvideo.com/stickers/p/1kl8'); }\
                 .cat-stickers#grukklama-css { left: 155px; background-image: url('https://image.jeuxvideo.com/stickers/p/1lgg'); }\
                 .cat-stickers#bud-css { left: 180px; background-image: url('https://image.jeuxvideo.com/stickers/p/1f8a'); }\
                 .cat-stickers#euro-css { left: 205px; background-image: url('https://image.jeuxvideo.com/stickers/p/1n1m'); }\
                 .cat-stickers#larspon-css { left: 230px; background-image: url('https://image.jeuxvideo.com/stickers/p/1lte'); }");
    // Script title
    GM_addStyle(".script-title { font-family: 'robotoboldcondensed' ,Arial,Helvetica,sans-serif; text-transform: uppercase; font-size: 0.75rem; color: #656574 }");
    // Stickers panel
    GM_addStyle(".new-stickers { border-top: 1px solid #ccc; padding: 2px; margin-top: 8px; height: 75px; transition: background-color 0.1s; overflow: auto; text-align: center; padding-top: 10px; scroll-behavior: smooth; }");
    // Catégories
    GM_addStyle(".cat-stickers { position: absolute; top:-8px; background-color: #E6E6E6; box-shadow: 0px 2px 2px #e0e0e0 ; border: 1px solid #ccc; border-radius: 50px; height: 16px; width: 16px; cursor: pointer; background-size: cover; background-repeat: no-repeat; background-position: center center; }");
    // Hover stickers
    GM_addStyle(".stickers-script:hover { background-color: rgba(185, 185, 185, 0.5); border-radius: 3px; }");
    if (document.URL.includes("jeuxvideo.com/messages-prives")){
        GM_addStyle(".stickers-script:hover { filter: grayscale(100%); }");
    }
    // Hover cat
    GM_addStyle(".cat-stickers:hover { box-shadow: 0px 2px 8px #b5b5b5; }");

    //Desactiver stickers intégrés si JVChat MP activé en MP
    window.addEventListener('jvchat:activation', function(event) {
        if (document.URL.includes("jeuxvideo.com/messages-prives")){
            //var oldstickssjvc = document.getElementById('old-stickjvc');
            //oldstickssjvc && (oldstickssjvc.disabled = true);
            //$(".new-stickers#"+currentDiv).hide(0);
        }
    });

})();