Fluffy_Stick_JV

StickersJVC vous permet d'utiliser les stickers JVC rapidement.

当前为 2023-11-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fluffy_Stick_JV
  3. // @author ImThatGuy_edit_New_Atlantis
  4. // @description StickersJVC vous permet d'utiliser les stickers JVC rapidement.
  5. // @namespace Fluffy_Stick_JV
  6. // @match *://www.jeuxvideo.com/messages-prives/nouveau.php*
  7. // @match *://www.jeuxvideo.com/messages-prives/message.php*
  8. // @match *://www.jeuxvideo.com/forums/42-*
  9. // @match *://www.jeuxvideo.com/forums/1-*
  10. // @match *://www.jeuxvideo.com/forums/0-*
  11. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/tipso/1.0.8/tipso.min.js
  13. // @grant GM_addStyle
  14. // @version 0.4.3_v92
  15. // @icon https://image.jeuxvideo.com/stickers/p/1jnh
  16. // @license MIT
  17. // ==/UserScript==
  18.  
  19. /*
  20. StickersJVC. 2018-2023.
  21. Code de base par ImThatGuy
  22.  
  23. */
  24.  
  25.  
  26. //___Dependance__jquery__________________
  27.  
  28. (function($, window, document, undefined) {
  29.  
  30. 'use strict';
  31.  
  32. var plugin = 'nuContextMenu';
  33.  
  34. var defaults = {
  35. hideAfterClick: false,
  36. contextMenuClass: 'nu-context-menu',
  37. activeClass: 'active'
  38. };
  39.  
  40. var nuContextMenu = function(container, options) {
  41. this.container = $(container);
  42. this.options = $.extend({}, defaults, options);
  43. this._defaults = defaults;
  44. this._name = plugin;
  45. this.init();
  46. };
  47.  
  48. $.extend(nuContextMenu.prototype, {
  49. init: function() {
  50.  
  51. if (this.options.items) {
  52. this.items = $(this.options.items);
  53. }
  54.  
  55. if (this._buildContextMenu()) {
  56. this._bindEvents();
  57. this._menuVisible = this._menu.hasClass(this.options.activeClass);
  58. }
  59. },
  60.  
  61. _getCallback: function() {
  62. return ((this.options.callback && typeof this.options.callback ===
  63. 'function') ? this.options.callback : function() {});
  64. },
  65.  
  66. _buildContextMenu: function() {
  67.  
  68. // Create context menu
  69. this._menu = $('<div>')
  70. .addClass(this.options.contextMenuClass)
  71. .append('<ul>');
  72.  
  73. var menuArray = this.options.menu,
  74. menuList = this._menu.children('ul');
  75.  
  76. // Create menu items
  77. $.each(menuArray, function(index, element) {
  78.  
  79. var item;
  80.  
  81. if (element !== null && typeof element !==
  82. 'object') {
  83. return;
  84. }
  85.  
  86. if (element.name === 'void') {
  87. item = $('<hr>');
  88. menuList.append(item);
  89. return;
  90. }
  91.  
  92. item = $('<li>')
  93. .attr('data-key', element.name)
  94. .text(' ' + element.title);
  95.  
  96. if (element.icon) {
  97. var icon = $('<i>')
  98. .addClass('fa fa-' + element.icon.toString());
  99. item.prepend(icon);
  100. }
  101.  
  102. menuList.append(item);
  103.  
  104. });
  105.  
  106. $('body')
  107. .append(this._menu);
  108.  
  109. return true;
  110.  
  111. },
  112.  
  113. _pDefault: function(event) {
  114. event.preventDefault();
  115. event.stopPropagation();
  116. return false;
  117. },
  118.  
  119. _contextMenu: function(event) {
  120.  
  121. event.preventDefault();
  122.  
  123. // Store the value of this
  124. // So it can be used in the listItem click event
  125. var _this = this;
  126. var element = event.target;
  127.  
  128. if (this._menuVisible || this.options.disable) {
  129. return false;
  130. }
  131.  
  132. var callback = this._getCallback();
  133. var listItems = this._menu.children('ul')
  134. .children('li');
  135.  
  136. listItems.off()
  137. .on('click', function() {
  138.  
  139. var key = $(this)
  140. .attr('data-key');
  141. callback(key, element);
  142. if (_this.options.hideAfterClick) {
  143. _this.closeMenu();
  144. }
  145. });
  146.  
  147. this.openMenu();
  148. this._menu.css({
  149. 'top': event.pageY + 'px',
  150. 'left': event.pageX + 'px'
  151. });
  152.  
  153. return true;
  154. },
  155.  
  156. _onMouseDown: function(event) {
  157. // Remove menu if clicked outside
  158. if (!$(event.target)
  159. .parents('.' + this.options.contextMenuClass)
  160. .length) {
  161. this.closeMenu();
  162. }
  163. },
  164.  
  165. _bindEvents: function() {
  166.  
  167. if (this.items) {
  168. // Make it possible to bind to dynamically created items
  169. this.container.on('contextmenu', this.options.items,
  170. $.proxy(this._contextMenu,
  171. this));
  172. } else {
  173. this.container.on('contextmenu', $.proxy(this._contextMenu,
  174. this));
  175. }
  176.  
  177. // Remove menu on click
  178. $(document)
  179. .on('mousedown', $.proxy(this._onMouseDown, this));
  180.  
  181. },
  182.  
  183. disable: function() {
  184. this.options.disable = true;
  185. return true;
  186. },
  187.  
  188. destroy: function() {
  189. if (this.items) {
  190. this.container.off('contextmenu', this.options.items);
  191. } else {
  192. this.container.off('contextmenu');
  193. }
  194. this._menu.remove();
  195. return true;
  196. },
  197.  
  198. openMenu: function() {
  199. this._menu.addClass(this.options.activeClass);
  200. this._menuVisible = true;
  201. return true;
  202. },
  203.  
  204. closeMenu: function() {
  205. this._menu.removeClass(this.options.activeClass);
  206. this._menuVisible = false;
  207. return true;
  208. }
  209.  
  210. });
  211.  
  212. $.fn[plugin] = function(options) {
  213. var args = Array.prototype.slice.call(arguments, 1);
  214.  
  215. return this.each(function() {
  216. var item = $(this),
  217. instance = item.data(plugin);
  218. if (!instance) {
  219. item.data(plugin, new nuContextMenu(this, options));
  220. } else {
  221. if (typeof options === 'string' && options[0] !== '_' &&
  222. options !== 'init') {
  223. instance[options].apply(instance, args);
  224. }
  225. }
  226. });
  227. };
  228.  
  229. })(jQuery, window, document);
  230.  
  231. //Script_Stickers_Script_______
  232.  
  233. /*jshint multistr: true */
  234. (function() {
  235. 'use strict';
  236.  
  237. const version = "0.4.3";
  238. console.log("[StickersJVC version "+version+"]");
  239.  
  240. // IMPORT CSS
  241. $('head').append('<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/tipso/1.0.8/tipso.min.css"/>');
  242. $('head').append('<link rel="stylesheet" type="text/css" href="https://epmd.000webhostapp.com/files/nu-context-menu.css"/>');
  243.  
  244. // Current div
  245. //var currentDiv = "fluffy";
  246. var currentDiv = localStorage.getItem('currentDiv');
  247. currentDiv = currentDiv || "fluffy";
  248. // LISTS
  249. var _stickers_hap = [
  250. "http://image.jeuxvideo.com/stickers/p/1kki",
  251. "http://image.jeuxvideo.com/stickers/p/1kkn",
  252. "http://image.jeuxvideo.com/stickers/p/1lmk",
  253. "http://image.jeuxvideo.com/stickers/p/1kkl",
  254. "http://image.jeuxvideo.com/stickers/p/1lmh",
  255. "http://image.jeuxvideo.com/stickers/p/1ljr",
  256. "http://image.jeuxvideo.com/stickers/p/1kkh",
  257. "http://image.jeuxvideo.com/stickers/p/1kkk",
  258. "http://image.jeuxvideo.com/stickers/p/1lmn",
  259. "http://image.jeuxvideo.com/stickers/p/1ljm",
  260. "http://image.jeuxvideo.com/stickers/p/1ljq",
  261. "http://image.jeuxvideo.com/stickers/p/1ljl",
  262. "http://image.jeuxvideo.com/stickers/p/1kkm",
  263. "http://image.jeuxvideo.com/stickers/p/1kkj",
  264. "http://image.jeuxvideo.com/stickers/p/1kko",
  265. "http://image.jeuxvideo.com/stickers/p/1kkg"
  266.  
  267. ];
  268. var _stickers_noel = [
  269. "http://image.jeuxvideo.com/stickers/p/1kkr",
  270. "http://image.jeuxvideo.com/stickers/p/1kko",
  271. "http://image.jeuxvideo.com/stickers/p/1kkg",
  272. "http://image.jeuxvideo.com/stickers/p/1kkp",
  273. "http://image.jeuxvideo.com/stickers/p/1ljj",
  274. "http://image.jeuxvideo.com/stickers/p/1ljn",
  275. "http://image.jeuxvideo.com/stickers/p/1kkq",
  276. "http://image.jeuxvideo.com/stickers/p/1kks",
  277. "http://image.jeuxvideo.com/stickers/p/1ljo",
  278. "http://image.jeuxvideo.com/stickers/p/1ljp",
  279. "http://image.jeuxvideo.com/stickers/p/1kkt",
  280. "http://image.jeuxvideo.com/stickers/p/1lmm",
  281. "http://image.jeuxvideo.com/stickers/p/1kku",
  282. "http://image.jeuxvideo.com/stickers/p/1kkv",
  283. "http://image.jeuxvideo.com/stickers/p/1mqw",
  284. "http://image.jeuxvideo.com/stickers/p/1rzs",
  285. "http://image.jeuxvideo.com/stickers/p/1mqz",
  286. "http://image.jeuxvideo.com/stickers/p/1nu9"
  287. ];
  288. var _stickers_saumon = [
  289. "http://image.jeuxvideo.com/stickers/p/1lmj",
  290. "http://image.jeuxvideo.com/stickers/p/1nua",
  291. "http://image.jeuxvideo.com/stickers/p/1nub",
  292. "http://image.jeuxvideo.com/stickers/p/1mqv",
  293. "http://image.jeuxvideo.com/stickers/p/1nu7",
  294. "http://image.jeuxvideo.com/stickers/p/1lmi",
  295. "http://image.jeuxvideo.com/stickers/p/1lml",
  296. "http://image.jeuxvideo.com/stickers/p/1lmo",
  297. "http://image.jeuxvideo.com/stickers/p/1lmp",
  298. "http://image.jeuxvideo.com/stickers/p/1mqx",
  299. "http://image.jeuxvideo.com/stickers/p/1mqy",
  300. "http://image.jeuxvideo.com/stickers/p/1mr0",
  301. "http://image.jeuxvideo.com/stickers/p/1mr1",
  302. "http://image.jeuxvideo.com/stickers/p/1nu6",
  303. "http://image.jeuxvideo.com/stickers/p/1nu8"
  304. ];
  305. var _stickers_brid = [
  306. "http://image.jeuxvideo.com/stickers/p/1jnd",
  307. "http://image.jeuxvideo.com/stickers/p/1jnc",
  308. "http://image.jeuxvideo.com/stickers/p/1jne",
  309. "http://image.jeuxvideo.com/stickers/p/1jnf",
  310. "http://image.jeuxvideo.com/stickers/p/1jng",
  311. "http://image.jeuxvideo.com/stickers/p/1jnh",
  312. "http://image.jeuxvideo.com/stickers/p/1jni",
  313. "http://image.jeuxvideo.com/stickers/p/1jnj"
  314. ];
  315. var _stickers_rex = [
  316. "http://image.jeuxvideo.com/stickers/p/1lm9",
  317. "http://image.jeuxvideo.com/stickers/p/1lma",
  318. "http://image.jeuxvideo.com/stickers/p/1lmb",
  319. "http://image.jeuxvideo.com/stickers/p/1lmc",
  320. "http://image.jeuxvideo.com/stickers/p/1lmd",
  321. "http://image.jeuxvideo.com/stickers/p/1lme",
  322. "http://image.jeuxvideo.com/stickers/p/1lmf",
  323. "http://image.jeuxvideo.com/stickers/p/1lmg"
  324. ];
  325. var _stickers_fluffy = [
  326. "http://image.jeuxvideo.com/stickers/p/1kl8",
  327. "http://image.jeuxvideo.com/stickers/p/1klb",
  328. "http://image.jeuxvideo.com/stickers/p/1kl9",
  329. "http://image.jeuxvideo.com/stickers/p/1kl7",
  330. "http://image.jeuxvideo.com/stickers/p/1kl5",
  331. "http://image.jeuxvideo.com/stickers/p/1kl6",
  332. "http://image.jeuxvideo.com/stickers/p/1kl2",
  333. "http://image.jeuxvideo.com/stickers/p/1kl1",
  334. "http://image.jeuxvideo.com/stickers/p/1kl3",
  335. "http://image.jeuxvideo.com/stickers/p/1kky",
  336. "http://image.jeuxvideo.com/stickers/p/1kkz",
  337. "http://image.jeuxvideo.com/stickers/p/1kla",
  338. "http://image.jeuxvideo.com/stickers/p/1kl4",
  339. "http://image.jeuxvideo.com/stickers/p/1kl0"
  340. ];
  341. var _stickers_grukklama = [
  342. "http://image.jeuxvideo.com/stickers/p/1lgg",
  343. "http://image.jeuxvideo.com/stickers/p/1lgb",
  344. "http://image.jeuxvideo.com/stickers/p/1lga",
  345. "http://image.jeuxvideo.com/stickers/p/1lgc",
  346. "http://image.jeuxvideo.com/stickers/p/1lgd",
  347. "http://image.jeuxvideo.com/stickers/p/1lge",
  348. "http://image.jeuxvideo.com/stickers/p/1lgf",
  349. "http://image.jeuxvideo.com/stickers/p/1lgh",
  350. "http://image.jeuxvideo.com/stickers/p/1kgx",
  351. "http://image.jeuxvideo.com/stickers/p/1kgv",
  352. "http://image.jeuxvideo.com/stickers/p/1kgw",
  353. "http://image.jeuxvideo.com/stickers/p/1kgy",
  354. "http://image.jeuxvideo.com/stickers/p/1kgu",
  355. "http://image.jeuxvideo.com/stickers/p/1kh0",
  356. "http://image.jeuxvideo.com/stickers/p/1kh1",
  357. "http://image.jeuxvideo.com/stickers/p/1kgz"
  358. ];
  359. var _stickers_bud = [
  360. "http://image.jeuxvideo.com/stickers/p/zuc",
  361. "http://image.jeuxvideo.com/stickers/p/zu2",
  362. "http://image.jeuxvideo.com/stickers/p/zu6",
  363. "http://image.jeuxvideo.com/stickers/p/zu7",
  364. "http://image.jeuxvideo.com/stickers/p/zu8",
  365. "http://image.jeuxvideo.com/stickers/p/zu9",
  366. "http://image.jeuxvideo.com/stickers/p/zua",
  367. "http://image.jeuxvideo.com/stickers/p/zub",
  368. "http://image.jeuxvideo.com/stickers/p/1f88",
  369. "http://image.jeuxvideo.com/stickers/p/1f89",
  370. "http://image.jeuxvideo.com/stickers/p/1f8a",
  371. "http://image.jeuxvideo.com/stickers/p/1f8b",
  372. "http://image.jeuxvideo.com/stickers/p/1f8d",
  373. "http://image.jeuxvideo.com/stickers/p/1f8e",
  374. "http://image.jeuxvideo.com/stickers/p/1f8f"
  375. ];
  376. var _stickers_euro = [
  377. "http://image.jeuxvideo.com/stickers/p/1n1m",
  378. "http://image.jeuxvideo.com/stickers/p/1n1n",
  379. "http://image.jeuxvideo.com/stickers/p/1n1t",
  380. "http://image.jeuxvideo.com/stickers/p/1n1q",
  381. "http://image.jeuxvideo.com/stickers/p/1n1s",
  382. "http://image.jeuxvideo.com/stickers/p/1n1o"
  383. ];
  384. var _stickers_larspon = [
  385. "http://image.jeuxvideo.com/stickers/p/1lt9",
  386. "http://image.jeuxvideo.com/stickers/p/1lte",
  387. "http://image.jeuxvideo.com/stickers/p/1ltd",
  388. "http://image.jeuxvideo.com/stickers/p/1li4",
  389. "http://image.jeuxvideo.com/stickers/p/1jc3-fr",
  390. "http://image.jeuxvideo.com/stickers/p/1li5",
  391. "http://image.jeuxvideo.com/stickers/p/1n2d",
  392. "http://image.jeuxvideo.com/stickers/p/1n2i",
  393. "http://image.jeuxvideo.com/stickers/p/1n2j",
  394. "http://image.jeuxvideo.com/stickers/p/1n2m"
  395. ];
  396.  
  397.  
  398. var _stickers_fav = [];
  399.  
  400.  
  401. // FUNCTIONS
  402. function getCode(element) {
  403. return element.attr("src").split('/')[5];
  404. }
  405.  
  406.  
  407. function idTextarea() {
  408. if (window.location.href.indexOf("messages-prives/message.php?") > -1) {
  409. return "#message";
  410. } else {
  411. return "#message_topic";
  412. }
  413. }
  414.  
  415. // MAIN APPEND
  416. var newStickers = '<div style="position: relative">\
  417. <div id="fav" class="new-stickers"></div>\
  418. <div id="hap" class="new-stickers"></div>\
  419. <div id="noel" class="new-stickers"></div>\
  420. <div id="saumon" class="new-stickers"></div>\
  421. <div id="brid" class="new-stickers"></div>\
  422. <div id="rex" class="new-stickers"></div>\
  423. <div id="fluffy" class="new-stickers"></div>\
  424. <div id="grukklama" class="new-stickers"></div>\
  425. <div id="bud" class="new-stickers"></div>\
  426. <div id="euro" class="new-stickers"></div>\
  427. <div id="larspon" class="new-stickers"></div>\
  428. </div>';
  429. $(newStickers).insertAfter('.jv-editor-toolbar');
  430.  
  431.  
  432.  
  433. // HIDES
  434. $(".new-stickers").each(function() {
  435. if ( $(this).attr("id") != currentDiv ) {
  436. $(this).hide();
  437. }
  438. });
  439.  
  440. // APPENDS
  441. let toolbar = document.querySelector(".jv-editor-toolbar")
  442. let imgBtnGroup = toolbar.querySelectorAll(".btn-group")[2]
  443. //btns = imgBtnGroup.querySelectorAll("button")
  444. let stickersBtn = document.createElement("button")
  445. stickersBtn.classList.add("btn")
  446. stickersBtn.classList.add("btn-jv-editor-toolbar")
  447. stickersBtn.setAttribute("id", "active-script")
  448. stickersBtn.setAttribute("type", "button")
  449. stickersBtn.innerHTML = "s"
  450. imgBtnGroup.appendChild(stickersBtn)
  451. $(".new-stickers").append('<div code="hap" id="hap-css" title="Hap" class="cat-stickers"></div>\
  452. <div code="noel" id="noel-css" title="Noel" class="cat-stickers"></div>\
  453. <div code="saumon" id="saumon-css" title="Saumon" class="cat-stickers"></div>\
  454. <div code="brid" id="brid-css" title="Bridgely" class="cat-stickers"></div>\
  455. <div code="rex" id="rex-css" title="Rex ryder" class="cat-stickers"></div>\
  456. <div code="fluffy" id="fluffy-css" title="Fluffy" class="cat-stickers"></div>\
  457. <div code="grukklama" id="grukklama-css" title="Grukk & Lama" class="cat-stickers"></div>\
  458. <div code="bud" id="bud-css" title="Bud" class="cat-stickers"></div>\
  459. <div code="euro" id="euro-css" title="Euro" class="cat-stickers"></div>\
  460. <div code="larspon" id="larspon-css" title="Larry & Sponsos" class="cat-stickers"></div>');
  461.  
  462. // AJOUT STICKERS
  463. for (var i = 0; i < _stickers_hap.length; i++) {
  464. $(".new-stickers#hap").append( '<img src="'+_stickers_hap[i]+'" class="stickers-script">' );
  465. }
  466. for (var k = 0; k < _stickers_noel.length; k++) {
  467. $(".new-stickers#noel").append( '<img src="'+_stickers_noel[k]+'" class="stickers-script">' );
  468. }
  469. for (var lz = 0; lz < _stickers_saumon.length; lz++) {
  470. $(".new-stickers#saumon").append( '<img src="'+_stickers_saumon[lz]+'" class="stickers-script">' );
  471. }
  472. for (var n = 0; n < _stickers_brid.length; n++) {
  473. $(".new-stickers#brid").append( '<img src="'+_stickers_brid[n]+'" class="stickers-script">' );
  474. }
  475. for (var j = 0; j < _stickers_rex.length; j++) {
  476. $(".new-stickers#rex").append( '<img src="'+_stickers_rex[j]+'" class="stickers-script">' );
  477. }
  478. for (var fff = 0; fff < _stickers_fluffy.length; fff++) {
  479. $(".new-stickers#fluffy").append( '<img src="'+_stickers_fluffy[fff]+'" class="stickers-script">' );
  480. }
  481. for (var gr = 0; gr < _stickers_grukklama.length; gr++) {
  482. $(".new-stickers#grukklama").append( '<img src="'+_stickers_grukklama[gr]+'" class="stickers-script">' );
  483. }
  484. for (var bd = 0; bd < _stickers_bud.length; bd++) {
  485. $(".new-stickers#bud").append( '<img src="'+_stickers_bud[bd]+'" class="stickers-script">' );
  486. }
  487. for (var euo = 0; euo < _stickers_euro.length; euo++) {
  488. $(".new-stickers#euro").append( '<img src="'+_stickers_euro[euo]+'" class="stickers-script">' );
  489. }
  490. for (var lx = 0; lx < _stickers_larspon.length; lx++) {
  491. $(".new-stickers#larspon").append( '<img src="'+_stickers_larspon[lx]+'" class="stickers-script">' );
  492. }
  493. for (var fv = 0; fv < _stickers_fav.length; fv++) {
  494. $(".new-stickers#fav").append( '<img src="'+_stickers_fav[fv]+'" class="stickers-script sticker-fav">' );
  495. }
  496.  
  497.  
  498. // Context menu
  499. var context = $('.new-stickers').nuContextMenu({
  500.  
  501. hideAfterClick: true,
  502.  
  503. items: '.stickers-script.sticker-fav',
  504.  
  505. callback: function(key, element) {
  506. if ( key == 'del' ) {
  507. $(element).remove();
  508. var index = _stickers_fav.indexOf( $(element).attr("src") );
  509. if (index > -1) {
  510. _stickers_fav.splice(index, 1);
  511. if (_stickers_fav.length < 1) {
  512. $("#fav").append('<p id="aucunFav">Vous n\'avez aucun sticker dans vos favoris.</p>');
  513. }
  514. }
  515. }
  516. },
  517.  
  518. menu: [
  519. ]
  520.  
  521. });
  522.  
  523. var context2 = $('body').nuContextMenu({
  524.  
  525. hideAfterClick: true,
  526.  
  527. items: '.stickers-script:not(.sticker-fav)',
  528.  
  529. callback: function(key, element) {
  530. if ( key == 'add' ) {
  531. var n = $(element).attr("src");
  532. if (_stickers_fav.indexOf(n) > -1) {
  533. // Le sticker est déjà en fav
  534. } else {
  535. if ($("#aucunFav").length > 0) { $("#aucunFav").remove(); }
  536. $("#fav").append('<img src="'+n+'" class="stickers-script sticker-fav">');
  537. $(".stickers-script").off("click"); // Destroy click event stickers
  538. stickersEvent();
  539. _stickers_fav.push(n);
  540. // Store fav
  541. }
  542. }
  543. },
  544.  
  545. menu: [
  546.  
  547. ]
  548.  
  549. });
  550.  
  551. // LISTENERS
  552. function stickersEvent() {
  553. $(".stickers-script").click(function() {
  554. // Get sticker code
  555. var code = getCode( $(this) );
  556. //$("#message_topic").val($("#message_topic").val() + " [[sticker:p/"+code+"]]");
  557. var $textarea = jQuery(idTextarea());
  558. var caretPos = $textarea[0].selectionStart;
  559. var textAreaTxt = $textarea.val();
  560.  
  561. var sticker = "[[sticker:p/"+code+"]] ";
  562.  
  563. $textarea.val(textAreaTxt.substring(0, caretPos) + sticker + textAreaTxt.substring(caretPos) );
  564. $textarea.focus();
  565. });
  566. }
  567. stickersEvent();
  568.  
  569. $(".cat-stickers").click(function() {
  570. var id = $(this).attr("code");
  571. // Sauvegarde du choix dans le localStorage
  572. localStorage.setItem('currentDiv', id);
  573. $(".new-stickers").each(function() {
  574. if ( $(this).attr("id") == id ) {
  575. $(this).show();
  576. if (currentDiv != id) {
  577. $("#"+currentDiv).hide();
  578. currentDiv = id;
  579. }
  580. }
  581. });
  582. });
  583.  
  584. // NICE SCROLL
  585. var lastScrollTop = 0;
  586. var ft_up = false;
  587. var ft_down = false;
  588. $(".new-stickers").scroll(function() {
  589. //console.log($(this).scrollTop());
  590. var st = $(this).scrollTop();
  591. //console.log(st);
  592. if (st > lastScrollTop) {
  593. if (!ft_up) {
  594. if (st < 50) {
  595. ft_up = true;
  596. $(this).scrollTop(50);
  597. }
  598. }
  599. } else {
  600. if (!ft_down) {
  601. if (st > 50) {
  602. ft_down = true;
  603. $(this).scrollTop(50);
  604. }
  605. }
  606. }
  607. lastScrollTop = st;
  608.  
  609. // Taille div
  610. if ($(this).scrollTop() != 0) { // Pas en haut de la div
  611. $(".cat-stickers").hide(55);
  612. } else {
  613. // En haut de la div
  614. $(".cat-stickers").show(55);
  615. ft_up = false;
  616. ft_down = false;
  617. }
  618. if ( $(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight ) {
  619. // En bas de la div
  620. ft_up = false;
  621. ft_down = false;
  622. }
  623. });
  624.  
  625. // Active script
  626. $(".new-stickers#"+currentDiv).hide(0);
  627. $("#active-script").click(function() {
  628. if ( $(".new-stickers").is(":visible") ) {
  629. $(this).removeClass("active");
  630. $(".new-stickers#"+currentDiv).hide(80);
  631. } else {
  632. $(this).addClass("active");
  633. $(".new-stickers#"+currentDiv).show(80);
  634. $(".new-stickers").css("overflow", "auto");
  635. }
  636. });
  637.  
  638. // TOOLTIPS
  639. $(document).ready(function() {
  640. $(".cat-stickers").each(function() {
  641. $(this).tipso({
  642. delay: 0,
  643. speed: 120,
  644. background: "rgba(0, 0, 0, 0.7)",
  645. size: 'tiny',
  646. content: '<b>'+$(this).attr("title")+'</b>',
  647. width: null,
  648. maxWidth: "150px"
  649. });
  650. });
  651. });
  652.  
  653. // CSS
  654. //GM_addStyle(".new-stickers:hover { background-color: #f9f9f9; }");
  655. // Scrollbar
  656. if (!$.browser.mozilla) {
  657. GM_addStyle(".new-stickers::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.2); background-color: #f7f7f7; }\
  658. .new-stickers::-webkit-scrollbar { width: 9px; background-color: #F5F5F5; }\
  659. .new-stickers::-webkit-scrollbar-thumb { background-color: #ccc; }");
  660. }
  661.  
  662. GM_addStyle(".stickers-script { height: 50px; width: 50px; cursor: pointer; padding: 2px; }");
  663.  
  664. GM_addStyle(".cat-stickers:hover { border: none; ");
  665. GM_addStyle(".cat-stickers#hap-css { left: 5px; background-image: url('https://i.imgur.com/QiaEFm9.png'); }\
  666. .cat-stickers#noel-css { left: 30px; background-image: url('https://i.imgur.com/xrdqIkA.png'); }\
  667. .cat-stickers#saumon-css { left: 55px; background-image: url('http://image.jeuxvideo.com/stickers/p/1mqv'); }\
  668. .cat-stickers#brid-css { left: 80px; background-image: url('http://image.jeuxvideo.com/stickers/p/1jnh'); }\
  669. .cat-stickers#rex-css { left: 105px; background-image: url('https://i.imgur.com/hc1pY1o.png'); }\
  670. .cat-stickers#fluffy-css { left: 130px; background-image: url('http://image.jeuxvideo.com/stickers/p/1kl8'); }\
  671. .cat-stickers#grukklama-css { left: 155px; background-image: url('https://i.imgur.com/raQso5Z.png'); }\
  672. .cat-stickers#bud-css { left: 180px; background-image: url('https://i.imgur.com/bYjXcMU.png'); }\
  673. .cat-stickers#euro-css { left: 205px; background-image: url('http://image.jeuxvideo.com/stickers/p/1n1m'); }\
  674. .cat-stickers#larspon-css { left: 230px; background-image: url('http://image.jeuxvideo.com/stickers/p/1lte'); }");
  675. // Script title
  676. GM_addStyle(".script-title { font-family: 'robotoboldcondensed' ,Arial,Helvetica,sans-serif; text-transform: uppercase; font-size: 0.75rem; color: #656574 }");
  677. // Stickers panel
  678. 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; }");
  679. // Catégories
  680. 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; }");
  681. // Hover stickers
  682. GM_addStyle(".stickers-script:hover { background-color: rgba(185, 185, 185, 0.5); border-radius: 3px; }");
  683. // Hover cat
  684. GM_addStyle(".cat-stickers:hover { box-shadow: 0px 2px 8px #b5b5b5; }");
  685. })();