ImThatGuy / Leviathan

// ==UserScript==
// @name         Leviathan
// @author       ImThatGuy
// @description  Les stickers JVC poussés à un niveau ultime !
// @connect      api.risibank.fr
// @include      http://www.jeuxvideo.com/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require      https://raw.githubusercontent.com/avxto/nuContextMenu/master/src/jquery.nu-context-menu.js
// @require      https://cdn.jsdelivr.net/npm/sweetalert2@8
// @require      https://jvcpremium.000webhostapp.com/files/tabs/jquery.tabs.min.js
// @require      https://jvcpremium.000webhostapp.com/files/tabs/tabs.js
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_xmlhttpRequest
// @version      0.1.0
// @icon         https://i.imgur.com/A2peeuf.png
// @copyright    2019+, ImThatGuy
// @license      MIT
// ==/UserScript==

/*
Leviathan. 2019.
Developpé par ImThatGuy.

2019+, ImThatGuy.

Changelog :
0.1.0 : 1re version.

*/

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

	var $ = window.jQuery;

	const version = '0.1.0';
	// CSS IMPORT
	// Icons
	$('head').append('<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">');
	// Context menu
	$('head').append('<link rel="stylesheet" type="text/css" href="https://jvcpremium.000webhostapp.com/files/nu-context-menu.css"/>');
	// ubuntu font
	$('head').append('<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">"/>');
	// Sweet alert
	$('head').append('<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css"/>');
	// Tabs
	$('head').append('<link rel="stylesheet" type="text/css" href="https://jvcpremium.000webhostapp.com/files/tabs/jquery.tabs.min.css"/>');
	// Tabs²
	$('head').append('<link rel="stylesheet" type="text/css" href="https://jvcpremium.000webhostapp.com/files/tabs/tabs.style.css"/>');

	function listeSujet() {
        if (document.getElementsByName('search_in_forum').length === 0) {
            return false;
        } else {return true;}
	}

	function darkJVC() {
		if ( $("body").css("background-color") == "rgb(18, 18, 18)" ) {
			return true;
		} else {
			return false;
		}
	}

	// Set default values
	 // First time
	if (GM_getValue("firstTime") == undefined) {
		GM_setValue("firstTime", true);
	}
	 // User Options
	if (GM_getValue("bgcolor") == undefined) {
		GM_setValue("bgcolor", "white");
	}
	if (GM_getValue("userStickers") == undefined) {
		GM_setValue("userStickers", JSON.stringify([]));
	}
	if (GM_getValue("btnAddSticker") == undefined) {
		GM_setValue("btnAddSticker", true);
	}
	if (GM_getValue("codes") == undefined) {
		GM_setValue("codes", JSON.stringify([]));
	}
	if (GM_getValue("tailleCadre") == undefined) {
		GM_setValue("tailleCadre", 130);
	}
	if (GM_getValue("darkMode") == undefined) {
		if (darkJVC()) {
			GM_setValue("darkMode", false);
		} else {
			GM_setValue("darkMode", true);
		}
		
	}
	if (GM_getValue("radiusStickers") == undefined) {
		GM_setValue("radiusStickers", 8);
	}
	// User options
	var userOptions = {
		bgcolor: GM_getValue("bgcolor"),
		userStickers: JSON.parse(GM_getValue("userStickers")),
		btnAddSticker: GM_getValue("btnAddSticker"),
		codes: JSON.parse(GM_getValue("codes")),
		tailleCadre: GM_getValue("tailleCadre"),
		darkMode: GM_getValue("darkMode"),
		radiusStickers: GM_getValue("radiusStickers")
	};

	//console.log(userOptions.codes);

	var currentDiv;
	if ( userOptions.userStickers.length === 0 ) {
		currentDiv = "#popStickers";
	} else { currentDiv = "#userStickers"; }


	var d ="linear-gradient(to right, rgba(86, 204, 242, 0.6), rgba(47, 128, 237, 0.5));"

	function addSticker(sticker) {
        var $textarea = $("#message_topic");
        var caretPos = $textarea[0].selectionStart;
        var textAreaTxt = $textarea.val();

		var txtToAdd = sticker + ' ';

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

	// refresh les indexs des codes
	function refreshCodesIndexs() {
		for (var i = 0; i<userOptions.codes.length; i++) {
			userOptions.codes[i].index = userOptions.codes.indexOf(userOptions.codes[i]);
		}
	}
	refreshCodesIndexs();

	// Premier lancement du script
	if (GM_getValue("firstTime")) {
		Swal.fire({
			title: '<strong>Bienvenue sur LEVIATHAN (v'+version+')</strong>',
			type: 'info',
			html:
			'<a href="#">Topic officiel</a> - <a href="https://openuserjs.org/scripts/ImThatGuy/Leviathan">Page userscript</a>',
			showCancelButton: false,
			showConfirmButton: false
		});
	}


	// Check pour DarkJVC
	if ( darkJVC() && userOptions.darkMode === false ) {
		Swal.fire({
			title: '<strong>Vous utilisez DarkJVC</strong>',
			type: 'info',
			html:
			'Pour un design optimal, veuillez activer le thème sombre de <b>Leviathan</b>. <div class="optionCadre"> <h4>Thème sombre</h4> <button id="darkModeModal" style="width: 50%;" class="Lbtn">Activer le thème sombre</button> </div>',
			showCancelButton: false,
			showConfirmButton: false
		});
	}



	// APPENDS
	$(".jv-editor-toolbar").append('<div style="font-family:ubuntu"> <div class="toolDiv"></div><div class="stickersDiv" id="popStickers"></div> <div class="stickersDiv" id="userStickers"></div> <div id="sOptions"></div> </div>');
	 // Options

	 // codes table
	var codesTable;
	if (userOptions.codes.length > 0) {
		codesTable = '<table class="codeTable">';
		for (var i = 0; i < userOptions.codes.length; i++) {
			codesTable+="<tr>";
			codesTable+='<td><img style="max-width: 55px; max-height: 55px;" src="'+userOptions.codes[i].url+'"</td>';
			codesTable+="<td>:"+userOptions.codes[i].code+":</td>";
			codesTable+='<td><button onclick="return false" class="Lbtn deleteCodeBtn" suppr-id="'+userOptions.codes[i].index+'">Supprimer</button></td>';

			codesTable+="</tr>";

		}
		codesTable+="</table>";
	} else {
		codesTable = "Pour définir un code, vous devez afficher le menu en cliquant droit sur un sticker (populaire ou personnel) puis choisir l'option 'définir un code'."
	}



	$("#sOptions").append(
		'<i>La modification d\'un paramètre peut nécessiter le rafraîchissement de la page pour prendre effet.</i><div class="jq-tab-wrapper" id="optionsTabs">\
		<div class="jq-tab-menu">\
			<div class="jq-tab-title active" data-tab="1">Ajouter un sticker</div>\
	<div class="jq-tab-title" data-tab="2">Mes codes</div>\
	<div class="jq-tab-title" data-tab="3">Autres options</div>\
	</div>\
	<div class="jq-tab-content-wrapper">\
		<div class="jq-tab-content active" data-tab="1">\
			<h4>Ajouter un sticker</h4> Ajouter un sticker via un lien (direct) noelshack <hr>\
		<div class="optionCadre"> <input class="Linput" id="stickerAddUrl" type="text" placeholder="Lien direct du sticker"> <button onclick="return false" id="addStickerBtn" class="Lbtn">Ajouter</button> </div>\
				</div>\
	<div class="jq-tab-content" data-tab="2">\
		<h4>Mes codes</h4> Les codes que vous avez défini <hr>\
'+codesTable+'\
			</div>\
	<div class="jq-tab-content" data-tab="3">\
      <h4>Autres options</h4> Tous les autres paramètres du script <hr>\
      <div class="tabs--block" id="optionsDetailsTabs">\
        <div class="tabs--header">\
          <div class="tab-head"><a href="javascript:;" rel="tab_1a"><span>Hauteur</span></a></div>\
          <div class="tab-head"><a href="javascript:;" rel="tab_2a"><span>Rayon</span></a></div>\
          <div class="tab-head"><a href="javascript:;" rel="tab_3a"><span>Réinitialiser</span></a></div>\
          <div class="tab-head"><a href="javascript:;" rel="tab_4a"><span>Thème</span></a></div>\
          <div class="tab-head"><a href="javascript:;" rel="tab_5a"><span>Bouton</span></a></div>\
        </div>\
        <div class="tabs--content">\
          <div class="tab-content" id="tab_1a"><div class="optionCadre"> <h4>Hauteur du cadre</h4> <input type="range" min="50" max="500" value="'+userOptions.tailleCadre+'" class="slider" id="tailleCadre"> <span id="rangeCadreValue"><b>'+userOptions.tailleCadre+'</b>px</span> <center> <button onclick="return false" id="tailleCadreBtn" class="Lbtn">Définir</button> </center> </div></div>\
          <div class="tab-content" id="tab_2a"><div class="optionCadre"> <h4>Rayon des stickers</h4> <input type="range" min="0" max="25" value="'+userOptions.radiusStickers+'" class="slider" id="radiusStickers"> <span id="rangeRadiusValue"><b>'+userOptions.radiusStickers+'</b>px</span> <div id="stickerRadiusExample" class="xStickers"><img class="xStickersImg" src="http://image.noelshack.com/fichiers/2018/29/6/1532128784-risitas33.png"></div> <center> <button onclick="return false" id="radiusStickersBtn" class="Lbtn">Définir</button> </center> </div></div>\
          <div class="tab-content" id="tab_3a"><div class="optionCadre"> <h4>Réinitialiser la liste de stickers personnels</h4> <center> <button onclick="return false" id="resetStickers" style="width: 50%;" class="Lbtn">Supprimer mes stickers</button> </center> </div></div>\
          <div class="tab-content" id="tab_4a"><div class="optionCadre"> <h4>Thème sombre</h4> <center> <button onclick="return false" id="darkMode" style="width: 50%;" class="Lbtn">Activer/désactiver le thème sombre</button> </center> </div></div>\
          <div class="tab-content" id="tab_5a"><div class="optionCadre"> <h4>Bouton d\'ajout de stickers</h4> <center> <button onclick="return false" id="optionAddSticker" style="width: 80%;" class="Lbtn">Activer/désactiver le bouton d\'ajout de stickers sur les topics</button> </center> </div></div>\
        </div>\
      </div>\
    </div>\
	</div>\
	</div>'
	);

	$(function(){
		$('#optionsTabs').jqTabs();
		$('#optionsDetailsTabs').createTabs();
	});

	// Lis les gifs noelshack et enlève le fond blanc des stickers transparent sur les miniatures
	var imgs = $(".img-shack");
	imgs.each(function() {
		var calt = $(this).attr("alt");
		if (calt.indexOf("fichiers") !== -1) {
			$(this).attr("src", calt);
		}
	});

	// Afficher la bonne div
	$("#popStickers, #userStickers, #sOptions").hide();
	$(currentDiv).show();

	// Texte chargement stickers
	$("#popStickers").append("Chargement des stickers populaires risibank...");

	// toolbar
	$(".toolDiv").append('<span style="float:right; font-weight: bold;"><img style="max-height:20px; max-width:20px; " src="https://i.imgur.com/ORxyXdp.png"> LEVIATHAN v'+version+'</span> <div class="toolBtn"><span data="popStickers"><i class="fas fa-user-alt"></i> Stickers populaires</span> <span data="userStickers"><i class="fas fa-user-lock"></i> Mes stickers</span> <span data="sOptions"><i class="fas fa-user-cog"></i> Options</span></div>');

	function appendStickers(list, selector, user) {
		for (var i=0; i<list.length; i++) {
			if (user) {
				$(selector).append('<div class="xStickers"><img class="xStickersImg userStickers" src="'+list[i]+'"></div>');
			} else {
				$(selector).append('<div class="xStickers"><img class="xStickersImg" src="'+list[i]+'"></div>');
			}
		}
		//console.log(list);

		// Event pour les stickers
		$(".xStickersImg").off().click(function() {
			addSticker($(this).attr("src"));
		});
	}

	function addCode(stickerUrl, codeA) {
		userOptions.codes.push({
			url: stickerUrl,
			code: codeA,
			index: userOptions.codes.length
		});
		GM_setValue("codes", JSON.stringify(userOptions.codes));
		Swal.fire("Enregistré !",
				  "Votre code a été crée. <br/> Pour l'utiliser, il suffit de l'écrire dans votre post <br/> <b style='font-size:22px;'>:" + codeA + ":</b>",
				  "success");
	}

	function deleteCodeByIndex(index) {
		userOptions.codes.splice(index, 1);
	}

	function defineSupprId() {
		var x = 0;
		$(".deleteCodeBtn").each(function() {
			$(this).attr("suppr-id", x);
			x+=1;
		});
	}

	GM_xmlhttpRequest({
		method: "GET",
		url: "https://api.risibank.fr/api/v0/load",
		headers: {
			"Content-Type": "application/x-www-form-urlencoded"
		}, onload: function (response) {
			var r = JSON.parse(response.responseText);
			var popList= [];
			for (var i=0; i<r.stickers.views.length; i++) {
				popList.push(r.stickers.views[i].risibank_link);
			}
			$("#popStickers").empty();
			appendStickers(popList, "#popStickers", false);
		}
	});

	// Pour afficher les stickers de l'utilisateur
	if (userOptions.userStickers.length > 0) {
		appendStickers(userOptions.userStickers, "#userStickers", true);
	} else {
		$("#userStickers").append('<p id="aucunFav">Vous n\'avez aucun sticker dans vos favoris.</p>');
	}

	// Bouton pour ajouter les stickers via un topic
	if (userOptions.btnAddSticker) {
		if (!listeSujet()) {
			if (userOptions.btnAddSticker) {
				$('<div class="addStickerIconDiv" style="display: inline-block; width: 68px!important; height: 51px!important; position:absolute"><fdp class="fas fa-plus-circle addStickerIcon"></fdp></div>').insertBefore('.img-shack').parent().css("position", "relative");
			}
		}
	}

	// Focus sur le bouton
	if (currentDiv == "#popStickers") {
		$('.toolBtn span[data="popStickers"]').addClass("active");
	} else if (currentDiv == "#userStickers") {
		$('.toolBtn span[data="userStickers"]').addClass("active");
	}

	// Some events
	$(".toolBtn span").click(function() {
		$(".toolBtn span").removeClass("active")
		$(this).addClass("active");

		$(currentDiv).hide();
		$("#"+$(this).attr("data")).show();
		currentDiv = "#"+$(this).attr("data");
	});

	$(".addStickerIcon").click(function() {
		var stickerElement = $(this).parent().parent().find(".img-shack");
		Swal.fire('Succès !', '<img style="max-width: 55px; max-height: 55px;" src="'+stickerElement.attr("src")+'"><br/> Sticker ajouté à votre liste de stickers.', 'success');
		userOptions.userStickers.push( $(this).parent().next().attr("src") );
		GM_setValue("userStickers", JSON.stringify(userOptions.userStickers));
		return false;
	});

	$(".addStickerIconDiv").hover(function() {
		$(this).find(".addStickerIcon").css("visibility", "visible");
	}, function() {
		$(this).find(".addStickerIcon").css("visibility", "hidden");
	});

	 // Event pour les codes
	$("#message_topic").keyup(function() {
		for (var m = 0; m < userOptions.codes.length; m++) {
			if ( $(this).val().indexOf( ":"+userOptions.codes[m].code+":" ) > -1 ) {
				$(this).val(
					$(this).val().replace( ":"+userOptions.codes[m].code+":", userOptions.codes[m].url )
				);
			}
		}
	});

	 // Ajouter un sticker via URL
	$("#addStickerBtn").click(function() {
		var data = $("#stickerAddUrl").val();
		if (data) {
			userOptions.userStickers.push( data );
			GM_setValue("userStickers", JSON.stringify(userOptions.userStickers));
			Swal.fire('Succès !', '<img style="max-width: 55px; max-height: 55px;" src="'+data+'"><br/> Sticker ajouté à votre liste de stickers.', 'success');
		}
	});

	 // Delete code btn
	$(".deleteCodeBtn").click(function() {
		$(this).parent().remove();
		var id = $(this).attr("suppr-id");
		var codeName = userOptions.codes[id].code;

		deleteCodeByIndex(id);
		defineSupprId(); // Actualise l'attr suppr-id pour qu'il corresponde à la liste

		GM_setValue("codes", JSON.stringify(userOptions.codes)); // Save
		Swal.fire('Succès !', 'Le code <b>' + codeName + '</b> a bien été supprimé.', 'success');
	});

	 // Autres options

	$("#tailleCadreBtn").click(function() {
		var e = $("#tailleCadre").val();
		GM_setValue("tailleCadre", e);
		Swal.fire('Succès !', 'La hauteur du cadre a été définie à '+e+'px.', 'success');
	});

	  // Radius
	$("#radiusStickers, #tailleCadre").on("mousemove", function() {
		var e = $(this).val();

		if ($(this).attr("id") == "tailleCadre") {
			$("#rangeCadreValue").empty().append("<b>"+e+"</b>px");
		} else {
			$("#rangeRadiusValue").empty().append("<b>"+e+"</b>px");
			$("#stickerRadiusExample").css("border-radius", e+"px");
		}

	});
	$("#radiusStickersBtn").click(function() {
		var e = $("#radiusStickers").val();
		GM_setValue("radiusStickers", e);
		Swal.fire('Succès !', 'Le rayon des stickers a été défini à '+e+'px.', 'success');
	});

	$("#resetStickers").click(function() {
		Swal.fire({
			title: 'Êtes-vous sûr ?',
			text: "Cela supprimera tous vos stickers personnels.",
			type: 'warning',
			showCancelButton: true,
			confirmButtonColor: '#3085d6',
			cancelButtonColor: '#d33',
			confirmButtonText: 'Oui, tout supprimer',
			cancelButtonText: 'Annuler'
		}).then((result) => {
			if (result.value) {
				GM_setValue("userStickers", JSON.stringify([]));
				Swal.fire(
					'Supprimé',
					"Votre liste de stickers personnels a été remise à zéro.",
					'success'
				);
			}
		});
	});

	$("#darkMode, #darkModeModal").click(function() {
		var msg;
		if (userOptions.darkMode) {
			userOptions.darkMode = false;
			msg = "Le thème sombre a été désactivé. Veuillez rafraîchir la page.";
		} else {
			userOptions.darkMode = true;
			msg = "Le thème sombre a été activé. Veuillez rafraîchir la page.";
		}
		GM_setValue("darkMode", userOptions.darkMode);
		Swal.fire('Succès !', msg, 'success');
	});

	$("#optionAddSticker").click(function() {
		var msg;
		if (userOptions.btnAddSticker) {
			userOptions.btnAddSticker = false;
			msg = "Le bouton d'ajout de stickers sur les topics a été désactivé";
		} else {
			userOptions.btnAddSticker = true;
			msg = "Le bouton d'ajout de stickers sur les topics a été activé";
		}
		GM_setValue("btnAddSticker", userOptions.btnAddSticker);
		Swal.fire('Succès !', msg, 'success');
	});

	// Context menu

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

		hideAfterClick: true,

		items: '.xStickers',

		callback: function(key, element) {
			if ( key == 'code' ) {

				Swal.fire({
					title: 'Créer un code',
					html: '<img style="max-width: 55px; max-height: 55px;" src="' + $(element).attr("src") + '">',
					input: 'text',
					showCancelButton: true,
					cancelButtonText: "Annuler",
					inputValidator: (value) => {
						if (!value) {
							return 'Vous devez entrer un code.'
						}
					}
				}).then((codeAdd) => {

					if (codeAdd.value) {

						var action;
						var LL;

						for (var i=0; i<userOptions.codes.length; i++) {
							if ( userOptions.codes[i].url ==  $(element).attr("src")) {
								action = "replace";
								LL = userOptions.codes[i];
							} else if ( userOptions.codes[i].code ==  codeAdd.value ) {
								action = "replaceif";
								LL = userOptions.codes[i];
							}
						}

						if ( action ) {
							if ( action == "replace" ) {
								deleteCodeByIndex(LL.index);
								addCode($(element).attr("src"), codeAdd.value);
							} else {
								Swal.fire({
									title: 'Êtes-vous sûr ?',
									text: "Cela remplacera le code précédemment défini.",
									type: 'warning',
									showCancelButton: true,
									confirmButtonColor: '#3085d6',
									cancelButtonColor: '#d33',
									confirmButtonText: 'Oui, remplacer le code',
									cancelButtonText: 'Annuler'
								}).then((result) => {
									if (result.value) {
										deleteCodeByIndex(LL.index);
										addCode($(element).attr("src"), codeAdd.value);
										Swal.fire(
											'Remplacé',
											"Votre code a été crée. <br/> Pour l'utiliser, il suffit de l'écrire dans votre post <br/> <b style='font-size:22px;'>:" + codeAdd.value + ":</b>",
											'success'
										);
									}
								});
							}
						} else {
							addCode($(element).attr("src"), codeAdd.value);
						}

					}
				});

			} else if ( key == 'reply' ) {
				addSticker($(element).attr('src'));
			} else if ( key == 'suppr' ) {

				// Clear the array
				userOptions.userStickers = userOptions.userStickers.filter(function (el) {
					return el != null;
				});
				GM_setValue("userStickers", JSON.stringify(userOptions.userStickers));


				var div = false;
				if ($(element).children().hasClass("userStickers")) {
					// Click on Div
					div = true;
				} else {
					div = false;
				}

				if ($(element).hasClass("userStickers") || $(element).children().hasClass("userStickers")) {


					var index;
					if (div) {
						$(element).remove();
						index = userOptions.userStickers.indexOf( $(element).children().attr("src") );
					} else {
						$(element).parent().remove();
						index = userOptions.userStickers.indexOf( $(element).attr("src") );
					}
					if (index > -1) {
						userOptions.userStickers.splice(index, 1);
						if (userOptions.userStickers.length < 1) {
							$("#userStickers").append('<p id="aucunFav">Vous n\'avez aucun sticker dans vos favoris.</p>');
						}
						GM_setValue("userStickers", JSON.stringify(userOptions.userStickers));
					}
				} else {
					Swal.fire('Erreur', 'Vous ne pouvez pas supprimer ce sticker.', 'error');
				}

				
			} else {
				// dunno
			}
		},

		menu: [

			{
				name: 'code',
				title: 'Définir un code',
				icon: 'plus',
			},

			{
				name: 'reply',
				title: 'Ajouter à mon post',
				icon: 'reply',
			},

			{
				name: 'void'
			},

			{
				name: 'suppr',
				title: 'Supprimer',
				icon: 'trash',
			},
		]

	});


	/*userOptions.userStickers.push(null);
	GM_setValue("userStickers", JSON.stringify(userOptions.userStickers));*/

	// Events


	// CSS
	 // Stickers
	GM_addStyle(".stickersDiv { border: none; margin-bottom: 5px; background: "+userOptions.bgcolor+"; font-family: ubuntu; color: black; height: "+userOptions.tailleCadre+"px; border-radius: 3px; overflow: auto; }");
	GM_addStyle(".xStickers { position: relative; display: inline-block; overflow: hidden; margin: 0 auto; width: 50px; height: 50px; margin-right: 12.5px; border-radius: "+userOptions.radiusStickers+"px; box-shadow: #bbb 1px 1px 2px; }");
	GM_addStyle(".xStickersImg { max-height: 68px; max-width: 68px; position: absolute; bottom:0; cursor: pointer; transition: 0.1s; opacity: 0.9; }\
                 .xStickersImg:hover { transform: scale(1.05, 1.05); opacity: 1; }\
                 .xStickersImg:active { transform: scale(1.1, 1.1);");

	 // Toolbar
	GM_addStyle(".toolDiv { padding: 5px; width: 100%; border: 1px solid #ccc; margin-bottom: 5px;  color: black; background-color: #fff; border-radius:5px; }");
	GM_addStyle(".toolBtn { display: inline-block; } .toolBtn span { border: none; border-radius: 5px; padding: 5px; margin-right: 10px; background: #eee; color: #444; cursor: pointer; transition: 0.1s; } .toolBtn span.active { background: #d4d4d4; } .toolBtn span:hover { background-color: #ddd; } ");
	//GM_addStyle(".toolBtn span:hover { background: #999; }");
	GM_addStyle("#sOptions { background-color: white; padding: 10px; border-radius: 3px; margin-bottom: 5px; max-height: 600px; overflow: auto;}");
	  // Icon
	GM_addStyle('.addStickerIcon { position:absolute; height: 14px!important; width: 14px!important; filter: drop-shadow( 1px 1px 1px #555); color: #fff; visibility: hidden; right:0; font-size: 14px; } .addStickerIcon:active { transform: scale(0.9, 0.9); }');
	  // Table
	GM_addStyle(".codeTable, .codeTable th, .codeTable td { padding: 2px; border: 1px solid #ccc; border-radius: 2px; border-collapse: collapse; width: 30%; text-align: center; }");
	  // inputs
	GM_addStyle(".Linput { padding: 4px; border: 1px solid #ccc; border-radius: 4px; outline: none; width: 70%; }");
	  // Btn's
	GM_addStyle(".Lbtn { padding: 4px; border: 1px solid #ccc; border-radius: 4px; background-color: #f7f7f7; outline: none; width: 65px; } .Lbtn:active { background-color: #eee; }");
	 // Options
	GM_addStyle(".optionCadre { background-color: #eee; padding: 10px; margin: 5px; border-radius: 4px; } .optionCadre h4 { font-size: 15px; } .optionCadre > h4 { text-align: center; }");

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

	// Dark mode
	if (userOptions.darkMode) {
		GM_addStyle(".stickersDiv, #sOptions { background-color: #292929; color: #eee; }\
.toolBtn span { background-color: #222; color: #eee; border: 1px solid #444; } .toolBtn span.active { background-color: #444; color: #eee; border: 1px solid #666; } .toolBtn span:hover { background-color: #333; }\
.toolDiv { background-color: #222; border: none; color: #eee; }\
.xStickers { box-shadow: none; border: 1px solid #333; }\
.optionCadre { background-color: #222; }\
.Lbtn { background-color: #222; color: #eee; border-color: #333} .Lbtn:active { background-color: #444; }\
.jq-tab-menu .jq-tab-title { color: #222; }\
.tabs--content, .tab-head a, .tab-head:last-child { border-color: #444; } .tab-head__active a, .tab-head a { background-color: #333; } .tab-head a { color: #999; } .tabs--header { box-shadow: 0 -1px 0 #444 inset; }");
	}

	// Fin
	if (GM_getValue("firstTime")) {
		GM_setValue("firstTime", false);
	}


})();