KG_Full_Emoticons

Display a popup panel with every available emoticon on the site, remembering the last selected emoticon per category by name.

当前为 2025-05-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         KG_Full_Emoticons
// @namespace    http://klavogonki.ru/
// @version      1.1.0
// @description  Display a popup panel with every available emoticon on the site, remembering the last selected emoticon per category by name.
// @match        *://klavogonki.ru/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=klavogonki.ru
// @grant        none
// ==/UserScript==

(()=>{"use strict";var e={56:(e,t,o)=>{e.exports=function(e){var t=o.nc;t&&e.setAttribute("nonce",t)}},72:e=>{var t=[];function o(e){for(var o=-1,n=0;n<t.length;n++)if(t[n].identifier===e){o=n;break}return o}function n(e,n){for(var i={},a=[],s=0;s<e.length;s++){var c=e[s],l=n.base?c[0]+n.base:c[0],u=i[l]||0,d="".concat(l," ").concat(u);i[l]=u+1;var p=o(d),m={css:c[1],media:c[2],sourceMap:c[3],supports:c[4],layer:c[5]};if(-1!==p)t[p].references++,t[p].updater(m);else{var g=r(m,n);n.byIndex=s,t.splice(s,0,{identifier:d,updater:g,references:1})}a.push(d)}return a}function r(e,t){var o=t.domAPI(t);o.update(e);return function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;o.update(e=t)}else o.remove()}}e.exports=function(e,r){var i=n(e=e||[],r=r||{});return function(e){e=e||[];for(var a=0;a<i.length;a++){var s=o(i[a]);t[s].references--}for(var c=n(e,r),l=0;l<i.length;l++){var u=o(i[l]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}i=c}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},314:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var o="",n=void 0!==t[5];return t[4]&&(o+="@supports (".concat(t[4],") {")),t[2]&&(o+="@media ".concat(t[2]," {")),n&&(o+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),o+=e(t),n&&(o+="}"),t[2]&&(o+="}"),t[4]&&(o+="}"),o})).join("")},t.i=function(e,o,n,r,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(n)for(var s=0;s<this.length;s++){var c=this[s][0];null!=c&&(a[c]=!0)}for(var l=0;l<e.length;l++){var u=[].concat(e[l]);n&&a[u[0]]||(void 0!==i&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=i),o&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=o):u[2]=o),r&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=r):u[4]="".concat(r)),t.push(u))}},t}},540:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},601:e=>{e.exports=function(e){return e[1]}},659:e=>{var t={};e.exports=function(e,o){var n=function(e){if(void 0===t[e]){var o=document.querySelector(e);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}t[e]=o}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(o)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(o){!function(e,t,o){var n="";o.supports&&(n+="@supports (".concat(o.supports,") {")),o.media&&(n+="@media ".concat(o.media," {"));var r=void 0!==o.layer;r&&(n+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),n+=o.css,r&&(n+="}"),o.media&&(n+="}"),o.supports&&(n+="}");var i=o.sourceMap;i&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,o)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},911:(e,t,o)=>{o.d(t,{A:()=>s});var n=o(601),r=o.n(n),i=o(314),a=o.n(i)()(r());a.push([e.id,"@import url(https://fonts.googleapis.com/css2?family=Noto+Color+Emoji&display=swap);"]),a.push([e.id,'.emoticons-popup{border-radius:.4em !important;box-shadow:0 8px 30px rgba(0,0,0,.12),0 4px 6px rgba(0,0,0,.04),0 2px 2px rgba(0,0,0,.08) !important;opacity:0;transition:opacity .3s cubic-bezier(0.25, 0.8, 0.25, 1);position:fixed;display:grid;grid-template-rows:50px auto;padding:.5em;gap:.5em;background-color:var(--popup-background);z-index:2000;top:20vh;left:50vw;transform:translateX(-50%);min-width:300px;width:800px;max-height:90vh;overflow:hidden}.emoticons-popup .header-buttons{display:flex;flex-direction:row;justify-content:space-between;gap:.5em}.emoticons-popup .header-buttons .clear-button{border-radius:.2em !important;border:none;cursor:pointer;box-sizing:border-box;width:50px;height:50px;font-size:1.4em;background:hsl(40,50%,15%)}.emoticons-popup .header-buttons .clear-button svg{stroke:#ca6}.emoticons-popup .header-buttons .category-buttons{display:flex;justify-content:center;gap:.5em;font-family:"Noto Color Emoji",sans-serif !important}.emoticons-popup .header-buttons .category-buttons .category-button{border-radius:.2em !important;border:none;cursor:pointer;box-sizing:border-box;width:50px;height:50px;font-size:1.4em;background:var(--default-button)}.emoticons-popup .header-buttons .category-buttons .category-button.active{background:var(--active-button)}.emoticons-popup .header-buttons .category-buttons .category-button:hover{background:var(--hover-button)}.emoticons-popup .header-buttons .category-buttons .category-button.disabled{opacity:.5;pointer-events:none}.emoticons-popup .header-buttons .close-button{border-radius:.2em !important;border:none;cursor:pointer;box-sizing:border-box;width:50px;height:50px;font-size:1.4em;background:hsl(0,50%,15%)}.emoticons-popup .header-buttons .close-button svg{stroke:#c66}.emoticons-popup .emoticon-buttons{display:grid;gap:.5em;overflow-y:auto;overflow-x:hidden;scrollbar-width:none}.emoticons-popup .emoticon-buttons::-webkit-scrollbar{display:none}.emoticons-popup .emoticon-buttons .emoticon-button{display:flex;justify-content:center;align-items:center;border-radius:.2em !important;border:none;cursor:pointer;position:relative;background:var(--default-button);padding:0}.emoticons-popup .emoticon-buttons .emoticon-button img{display:block}.emoticons-popup .emoticon-buttons .emoticon-button.selected{background:var(--selected-button);filter:sepia(0.7)}.emoticons-popup .emoticon-buttons .emoticon-button.favorite{background:var(--active-button)}.emoticons-popup .emoticon-buttons .emoticon-button:hover{background:var(--hover-button)}.emoticons-mobile-toggle{position:fixed !important;bottom:5em !important;right:-2px !important;transform:translateY(-50%) !important;z-index:1050 !important;display:flex;align-items:center !important;justify-content:center !important;padding:.4em !important;background-color:var(--foreground-color, #17191c) !important;font-size:18px !important;font-family:"Noto Color Emoji",sans-serif !important;font-weight:bold !important;border:1px solid var(--border-color, #4d4d4d) !important;border-radius:.4em 0 0 .4em !important;cursor:pointer !important;transition:background .2s ease,opacity .2s ease !important}@media screen and (max-width: 1200px){.emoticons-popup{width:100%;top:30px;max-height:70vh}.emoticons-popup .emoticon-buttons{max-height:calc(70vh - 70px)}}@media screen and (max-width: 500px){.emoticons-popup{display:flex;flex-direction:row;top:0}.emoticons-popup .header-buttons{flex-direction:column;justify-content:flex-start}.emoticons-popup .header-buttons .close-button,.emoticons-popup .header-buttons .clear-button{display:none}.emoticons-popup .header-buttons button{width:40px !important;height:40px !important}.emoticons-popup .header-buttons button svg{width:18px !important;height:18px !important}.emoticons-popup .header-buttons .category-buttons{flex-direction:column}.emoticons-popup .header-buttons .category-buttons .category-button{font-size:1.2em}.emoticons-popup .emoticon-buttons{display:flex;flex-direction:row;flex-wrap:wrap;min-height:320px}.emoticons-popup .emoticon-buttons .emoticon-button{min-height:40px;min-width:40px}}',""]);const s=a}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={id:n,exports:{}};return e[n](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.nc=void 0;var n=o(72),r=o.n(n),i=o(825),a=o.n(i),s=o(659),c=o.n(s),l=o(56),u=o.n(l),d=o(540),p=o.n(d),m=o(113),g=o.n(m),h=o(911),f={};f.styleTagTransform=g(),f.setAttributes=u(),f.insert=c().bind(null,"head"),f.domAPI=a(),f.insertStyleElement=p();r()(h.A,f);h.A&&h.A.locals&&h.A.locals;const y={Boys:["hello","hi","smile","wink","biggrin","laugh","happy","cool","rofl","rofl2","rolleyes","spiteful","crazy","acute","silence","tongue","whistle","music","ph34r","excl","no","yes","ok","bye","victory","good","clapping","dance","cult","power","boystroking","complaugh","badcomp","gamer","first","second","third","formula1","friends","popcorn","tea","beer","grats","birthday","holmes","kidtruck","musketeer","pioneer","mellow","dry","sleep","cry","sick","sorry","unsure","boredom","facepalm","scare","blink","sad","confuse","nervous","wacko","huh","ohmy","megashok","shok","bad","russian","dash","angry","angry2"],Girls:["cheerful","cheerleader","clapgirl","curtsey","enjoygift","girlblum","girlconfuse","girlcrazy","girlcry","girlicecream","girlimpossible","girlinlove","girlkiss","girlkissboy","girlmad","girlmusic","girlnervous","girlnotebook","girlobserve","girlrevolve","girlsad","umbrage","girlscare","girlshighfive","girlsick","girlsilence","girlstop","girlstroking","girlsuper","girltea","girlwacko","girlwink","girlwitch","girlwonder","goody","hairdryer","hiya","hysteric","kgagainstaz","kgrace","primp","respect","spruceup","spruceup1","supergirl","tender","angrygirl","girldevil"],Christmas:["firework","confetti","cheers","wine","champ","champ2","santa","santa2","santa3","snowhand","snowhit","heyfrombag","snowgirlwave","snowball","snegurochka","santasnegurka","snowman","merrychristmas","spruce","moose","christmasevil"],Inlove:["inlove","hug","boykiss","wecheers","wedance","adultery","cave","leisure","wedding","airkiss","kissed","flowers","grose","flowers2","rose","smell","frog","girlfrog","rocker","serenade","val","girlval","bemine","heartcake","heart2","girlheart2","girllove","nolove","heart","blush","wub"],Army:["uzi","ak47","barret","chaingun","pogranminigun","partizan","dandy","gangster","mafia","foolrifle","cowboy","armyscare","armystar","armyfriends","armytongue","soldier","bayanist","pogranmail","pogran","pogranflowers","pogranrose","pograntort","girlpogran","pogranmama","budenov","captain","vdv","comandos","kirpich","girlvdv","girlranker","ranker","girlrogatka","rogatka","radistka","prival","vtik","vpered","tank","fly"],Halloween:["alien","ghost","cyborg","robot","terminator","turtle","batman","bebebe","bite","corsair","girlpirate","indigenous","clown","jester","death","paladin","pirate","dwarf","pirates","witch","wizard","spider","diablo","vampire","carpet"],Favourites:[]},v={Boys:"🎩",Girls:"🎀‍",Christmas:"🎄",Inlove:"❤️",Army:"🔫",Halloween:"🎃",Favourites:"🌟"},b="22",w="http://www.w3.org/2000/svg",x="0 0 24 24",k=`\n  <svg xmlns="${w}"\n    width="${b}"\n    height="${b}"\n    viewBox="${x}"\n    stroke="currentColor"\n    fill="none"\n    stroke-width="2"\n    stroke-linecap="round"\n    stroke-linejoin="round">\n      <polyline points="3 6 5 6 21 6"></polyline>\n      <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>\n      <line x1="10" y1="11" x2="10" y2="17"></line>\n      <line x1="14" y1="11" x2="14" y2="17"></line>\n  </svg>`,E=`\n  <svg xmlns="${w}"\n    width="${b}"\n    height="${b}"\n    viewBox="${x}"\n    stroke="currentColor" \n    fill="none"\n    stroke-width="2"\n    stroke-linecap="round"\n    stroke-linejoin="round">\n      <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>\n      <line x1="9" y1="9" x2="15" y2="15"></line>\n      <line x1="15" y1="9" x2="9" y2="15"></line>\n  </svg>`;!function(){const e={eventListeners:[],activeCategory:localStorage.getItem("activeCategory")||"Boys",isPopupCreated:!1,categoryHistory:[],currentSortedEmoticons:[],lastFocusedInput:null,latestCategoryRequest:null,lastKeyTimes:{},lastUsedEmoticons:JSON.parse(localStorage.getItem("lastUsedEmoticons"))||{},isMobile:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||"ontouchstart"in window};const t=function(e){const t=e.match(/\d+/g);if(t&&3===t.length){const[e,o,n]=t.map(Number),r=Math.max(e,o,n)/255,i=Math.min(e,o,n)/255;return Math.round((r+i)/2*100)}return 0}(window.getComputedStyle(document.body).backgroundColor),o={popupBackground:n("popupBackground"),defaultButton:n("defaultButton"),hoverButton:n("hoverButton"),activeButton:n("activeButton"),selectedButton:n("selectedButton")};function n(e){const o={popupBackground:10,defaultButton:15,hoverButton:25,activeButton:35,selectedButton:45}[e]||0;return`hsl(0, 0%, ${t<50?t+o:t-o}%)`}function r(){return JSON.parse(localStorage.getItem("emoticonUsageData"))||{}}function i(t){const o=r();o[e.activeCategory]=o[e.activeCategory]||{},o[e.activeCategory][t]=(o[e.activeCategory][t]||0)+1,function(e){localStorage.setItem("emoticonUsageData",JSON.stringify(e))}(o)}function a(e){const t=r()[e]||{};return y[e].slice().sort(((e,o)=>(t[o]||0)-(t[e]||0)))}function s(e){return(JSON.parse(localStorage.getItem("favoriteEmoticons"))||[]).includes(e)}function c(){const e=window.location.pathname,t=window.location.hash,o=new URLSearchParams(window.location.search).get("gmid"),n=t.match(/#\/(\d+)\//);return{isForum:e.includes("/forum/"),isGamelist:e.includes("/gamelist/"),isGame:!!o,isProfile:"/u/"===e&&!!n,gmid:o||null,profileId:n?.[1]||null}}function l(e){!document.querySelector(".emoticons-popup")||"Escape"!==e.code&&"KeyQ"!==e.code||(e.preventDefault(),m())}function u(e){const t=document.querySelector(".emoticons-popup");t&&!t.contains(e.target)&&m()}function d(t){const o=c();let n=e.lastFocusedInput;if(!n){if(n=o.isForum?document.getElementById("fast-reply_textarea"):o.isGamelist?document.querySelector("#chat-general.chat .messages input.text"):o.isGame?document.querySelector('[id^="chat-game"].chat .messages input.text'):document.querySelector("#app-chat-container #message-input"),!n){const e={isForum:"the forum",isProfile:"the profile",isGamelist:"general chat",isGame:"game chat"},t=Object.entries(e).filter((([e])=>o[e])).map((([e,t])=>t)).join(", ");return void alert(`Please focus on a text field in ${t}.`)}e.isMobile||n.focus(),e.lastFocusedInput=n}const r=function(t){const{isForum:o}=c();return o&&e.lastFocusedInput&&"textarea"===e.lastFocusedInput.tagName.toLowerCase()?`[img]https://klavogonki.ru/img/smilies/${t}.gif[/img] `:`:${t}: `}(t),i=n.selectionStart||0;n.value=n.value.slice(0,i)+r+n.value.slice(i),n.setSelectionRange(i+r.length,i+r.length),e.isMobile||n.focus()}function p(e,t){"show"===t?(document.body.appendChild(e),requestAnimationFrame((()=>{e.style.opacity="1"}))):(e.style.opacity="0",setTimeout((()=>e.remove()),300))}function m(){const t=document.querySelector(".emoticons-popup");if(!t)return;e.eventListeners.forEach((({event:e,handler:t})=>{document.removeEventListener(e,t)})),e.eventListeners=[],p(t,"hide"),e.isPopupCreated=!1;const o=e.lastFocusedInput;if(o){o.focus();const e=o.value.length;o.setSelectionRange(e,e)}}function g(){e.isPopupCreated?m():setTimeout((()=>{!function(t){if(e.isPopupCreated)return;y.Favourites=JSON.parse(localStorage.getItem("favoriteEmoticons"))||[];const o=document.createElement("div");o.className="emoticons-popup";const n=document.createElement("div");n.className="header-buttons";const r=(e,t,o,n)=>{const r=document.createElement("button");return r.className=e,r.title=t,r.innerHTML=o,n&&r.addEventListener("click",n),r},i=r("clear-button","Clear usage data",k,(()=>{confirm("Clear emoticon usage data?")&&localStorage.removeItem("emoticonUsageData")})),a=r("close-button","Close emoticons panel",E,m);n.appendChild(i),n.appendChild(function(){const t=document.createElement("div");t.className="category-buttons";for(let o in y)if(Object.prototype.hasOwnProperty.call(y,o)){const n=document.createElement("button");n.className="category-button",n.innerHTML=v[o],n.dataset.category=o,n.title=o,o===e.activeCategory&&n.classList.add("active"),"Favourites"===o&&0===y.Favourites.length&&n.classList.add("disabled"),"Favourites"===o&&n.addEventListener("click",f),n.addEventListener("click",(e=>h(o,e))),t.appendChild(n)}return t}()),n.appendChild(a),o.appendChild(n),x(t).then((e=>{o.appendChild(e),requestAnimationFrame(S)})),o.addEventListener("dblclick",m);[{event:"keydown",handler:F},{event:"keydown",handler:L},{event:"keydown",handler:l},{event:"click",handler:u}].forEach((({event:t,handler:o})=>{e.eventListeners.push({event:t,handler:o}),document.addEventListener(t,o)})),document.body.appendChild(o),p(o,"show"),e.isPopupCreated=!0}(e.activeCategory)}),10)}function h(e,t){t.shiftKey||t.ctrlKey||w(e)}function f(t){t.ctrlKey&&(localStorage.removeItem("favoriteEmoticons"),y.Favourites=[],S(),e.categoryHistory.length&&(e.activeCategory=e.categoryHistory.pop(),localStorage.setItem("activeCategory",e.activeCategory),b(e.activeCategory),C()))}function b(e){document.querySelectorAll(".category-buttons button").forEach((t=>{t.dataset.category===e?t.classList.add("active"):t.classList.remove("active"),"Favourites"===t.dataset.category&&(0===y.Favourites.length?t.classList.add("disabled"):t.classList.remove("disabled"))}))}function w(t){"Favourites"===t&&0===y.Favourites.length||("Favourites"!==e.activeCategory&&e.categoryHistory.push(e.activeCategory),e.activeCategory=t,localStorage.setItem("activeCategory",e.activeCategory),e.currentSortedEmoticons=a(e.activeCategory),b(e.activeCategory),C())}async function x(t){const o=document.createElement("div");o.className="emoticon-buttons",e.currentSortedEmoticons=a(t);const n=[];e.currentSortedEmoticons.forEach((r=>{const a=document.createElement("button");a.className="emoticon-button";const c=`/img/smilies/${r}.gif`;a.innerHTML=`<img src="${c}" alt="${r}">`,a.title=r,r===e.lastUsedEmoticons[e.activeCategory]?a.classList.add("selected"):"Favourites"!==e.activeCategory&&s(r)&&a.classList.add("favorite"),n.push(new Promise((e=>{const t=new Image;t.onload=e,t.src=c}))),a.addEventListener("click",(o=>{if(o.stopPropagation(),o.shiftKey)d(r);else if(o.ctrlKey){const e=JSON.parse(localStorage.getItem("favoriteEmoticons"))||[],o=e.indexOf(r);"Favourites"===t&&-1!==o?(e.splice(o,1),y.Favourites.splice(o,1)):"Favourites"===t||e.includes(r)||(e.push(r),y.Favourites.push(r)),localStorage.setItem("favoriteEmoticons",JSON.stringify(e)),b(t),"Favourites"===t&&C()}else d(r),i(r),e.lastUsedEmoticons[e.activeCategory]=r,localStorage.setItem("lastUsedEmoticons",JSON.stringify(e.lastUsedEmoticons)),e.isMobile||m();S()})),o.appendChild(a)})),await Promise.all(n);const{maxImageWidth:r,maxImageHeight:c}=await async function(e){const t=34,o=await Promise.all(e.map((e=>new Promise((t=>{const o=new Image;o.onload=()=>t({width:o.width,height:o.height}),o.src=`/img/smilies/${e}.gif`}))))),n=Math.max(t,...o.map((e=>e.width))),r=Math.max(t,...o.map((e=>e.height)));return{maxImageWidth:n,maxImageHeight:r}}(e.currentSortedEmoticons);return Object.assign(o.style,{gridTemplateColumns:`repeat(auto-fit, minmax(${r}px, 1fr))`,gridAutoRows:`minmax(${c}px, auto)`}),o}function C(){const t=Date.now();e.latestCategoryRequest=t,document.querySelectorAll(".emoticon-buttons").forEach((e=>e.remove())),x(e.activeCategory).then((o=>{if(e.latestCategoryRequest!==t)return;const n=document.querySelector(".emoticons-popup");n&&(n.appendChild(o),S())}))}function S(){requestAnimationFrame((()=>{document.querySelectorAll(".emoticon-buttons button").forEach((t=>{const o=t.title;t.classList.remove("selected","favorite"),o===e.lastUsedEmoticons[e.activeCategory]?t.classList.add("selected"):"Favourites"!==e.activeCategory&&s(o)&&t.classList.add("favorite")}))}))}function I(t){const o=e.currentSortedEmoticons.indexOf(e.lastUsedEmoticons[e.activeCategory]);let n=-1===o?0:o+t;n<0&&(n=e.currentSortedEmoticons.length-1),n>=e.currentSortedEmoticons.length&&(n=0),e.lastUsedEmoticons[e.activeCategory]=e.currentSortedEmoticons[n],localStorage.setItem("lastUsedEmoticons",JSON.stringify(e.lastUsedEmoticons)),S()}function F(t){if(!document.querySelector(".emoticons-popup")||!e.currentSortedEmoticons||0===e.currentSortedEmoticons.length)return;if(new Set(["Enter","Semicolon","ArrowLeft","KeyJ","ArrowRight","KeyK"]).has(t.code))if(t.preventDefault(),"Enter"===t.code||"Semicolon"===t.code){const o=e.lastUsedEmoticons[e.activeCategory];o&&e.currentSortedEmoticons.includes(o)&&(d(o),i(o),t.shiftKey||m())}else"ArrowLeft"===t.code||"KeyJ"===t.code?I(-1):"ArrowRight"!==t.code&&"KeyK"!==t.code||I(1)}function L(t){if(!document.querySelector(".emoticons-popup")||!["Tab","KeyH","KeyL"].includes(t.code)&&("Tab"!==t.code||!t.shiftKey))return;t.preventDefault();const o=Object.keys(y),n=0===(JSON.parse(localStorage.getItem("favoriteEmoticons"))||[]).length?o.filter((e=>"Favourites"!==e)):o;let r=n.indexOf(e.activeCategory);-1===r&&(r=0);let i=("Tab"===t.code&&!t.shiftKey||"KeyL"===t.code)&&r<n.length-1?r+1:("KeyH"===t.code||"Tab"===t.code&&t.shiftKey)&&r>0?r-1:r;if(i===r)return;const s=n[i];e.currentSortedEmoticons=a(s),localStorage.setItem("activeCategory",s),w(s)}document.documentElement.style.setProperty("--popup-background",o.popupBackground),document.documentElement.style.setProperty("--default-button",o.defaultButton),document.documentElement.style.setProperty("--hover-button",o.hoverButton),document.documentElement.style.setProperty("--active-button",o.activeButton),document.documentElement.style.setProperty("--selected-button",o.selectedButton),Object.keys(y).forEach((t=>{Object.prototype.hasOwnProperty.call(e.lastUsedEmoticons,t)&&y[t].includes(e.lastUsedEmoticons[t])||(e.lastUsedEmoticons[t]=y[t][0]||"")})),function(){const t=document.createElement("button");t.className="emoticons-mobile-toggle",t.title="Open emoticons panel",t.innerHTML=v[e.activeCategory]||"😊",t.addEventListener("click",g),document.body.appendChild(t)}(),document.addEventListener("focusin",(function(t){t.target.matches("textarea, input.text, input#message-input")&&(e.lastFocusedInput=t.target)})),document.addEventListener("mouseup",(function(e){e.ctrlKey&&0===e.button&&e.target.matches("textarea, input.text, input#message-input")&&(e.preventDefault(),g())})),document.addEventListener("keydown",(function(t){if("KeyV"===t.code&&t.ctrlKey){document.querySelector(".emoticons-popup")&&m()}else"KeyQ"===t.code?function(t,o,n,r){const i=Date.now();t.code===o?i-(e.lastKeyTimes[o]||0)<n?(t.preventDefault(),r(),e.lastKeyTimes[o]=0):e.lastKeyTimes[o]=i:e.lastKeyTimes[o]=0}(t,"KeyQ",500,(function(){if(e.lastFocusedInput){let t=e.lastFocusedInput.value;t.length>=2&&t.slice(-1)===t.slice(-2,-1)?t=t.slice(0,-2):t.length>=1&&(t=t.slice(0,-1)),e.lastFocusedInput.value=t;const o=t.length;e.lastFocusedInput.setSelectionRange(o,o)}g()})):e.lastKeyTimes.KeyQ=0}))}()})();