Greasy Fork

Agma Chat Command Settings

Configure your settings using the chat.

目前为 2021-08-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         Agma Chat Command Settings
// @namespace    agma-chat-command-settings
// @version      2.1.0
// @description  Configure your settings using the chat.
// @author       Nuke
// @match        *://agma.io/
// @grant        none
// ==/UserScript==

!function(){var e={};Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_COMMAND=e.DEFAULT_OPTIONS=e.DEFAULT_INFORMATION=void 0,e.DEFAULT_INFORMATION={name:void 0,version:"1.0.0",description:void 0,author:void 0},e.DEFAULT_OPTIONS={silent:!1,chatElementSelector:void 0,prefix:"/",exposeToWindowObject:!1},e.DEFAULT_COMMAND={disabled:!1,clearChat:!0};var n={};Object.defineProperty(n,"__esModule",{value:!0}),n.error=n.warn=n.log=void 0,n.log=function(e){return console.log("(@agmajs/core)[LOG]: "+e)},n.warn=function(e){return console.warn("(@agmajs/core)[WARN]: "+e)},n.error=function(e){return console.error("(@agmajs/core)[ERROR]: "+e)};var t={};Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e};var i={};Object.defineProperty(i,"__esModule",{value:!0}),i.ChatContext=i.createChatContext=void 0,i.createChatContext=function(e){return new o(e)};var o=function(){function e(e){this._chatElement=document.querySelector(e)}return e.prototype.value=function(e){if(void 0===e)return this._chatElement.value;this._chatElement.value=e},e.prototype.clear=function(){this.value("")},e}();i.ChatContext=o;var a={},r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)},s=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t),Object.defineProperty(e,i,{enumerable:!0,get:function(){return n[t]}})}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),d=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&s(n,e,t);return d(n,e),n},l=this&&this.__spreadArray||function(e,n){for(var t=0,i=n.length,o=e.length;t<i;t++,o++)e[o]=n[t];return e};Object.defineProperty(a,"__esModule",{value:!0}),a.Script=a.createScript=void 0;var u=c(n);a.createScript=function(e,n){return new m(e,n)};var m=function(){function n(n,t){this._initialized=!1,this.information=Object.freeze(r(r({},e.DEFAULT_INFORMATION),n)),this.options=r(r({},e.DEFAULT_OPTIONS),t),this.plugins=new Set,this.commands=[],this.init(),this.options.exposeToWindowObject&&(window.$script?u.warn("There already is a script that's also using `@agmajs/script`.\n          Cancelling exposing to window object.."):window.$script=this)}return n.prototype.command=function(n,t){if(t)this.commands.includes(t)?this.options.silent||u.warn('Command "'+t.name+'" has already been registered'):(t=r(r(r({},e.DEFAULT_COMMAND),t),{name:n}),this.commands.push(t));else{if(t=this.commands.find((function(e){return e.name==n})))return t;for(var i=0;i<this.commands.length;i++)if((t=this.commands[i]).aliases&&("string"==typeof t.aliases&&n==t.aliases||Array.isArray(t.aliases)&&t.aliases.includes(n)))return t}return this},n.prototype.use=function(e){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return this.plugins.has(e)?!this.options.silent&&u.warn("Plugin has already been applied."):e&&t.isFunction(e)?(this.plugins.add(e),e.apply(void 0,l([this],n))):this.options.silent||u.error("A plugin must be a function."),this},n.prototype.init=function(){var e=this;if(!this._initialized){var n=this.options,t=n.chatElementSelector,o=n.prefix;if(!t)return;var a=document.querySelector(t);a.onkeydown=function(n){if("Enter"==n.key){var r=a.value;if(!r.startsWith(o))return;var s=r.trim().slice(null==o?void 0:o.length).split(/ +/g),d=s[0],c=s.slice(1),l=e.command(d.toLowerCase());if(l){if(l.disabled)return;var u=i.createChatContext(t);l.clearChat&&u.clear(),l.run(e,u,c)}}},this._initialized=!0}},n}();a.Script=m;var f={};Object.defineProperty(f,"__esModule",{value:!0}),f.defineCommand=void 0,f.defineCommand=function(e){return e};var p={};Object.defineProperty(p,"__esModule",{value:!0});var h={};Object.defineProperty(h,"__esModule",{value:!0});var y={};Object.defineProperty(y,"__esModule",{value:!0}),y.Script=void 0,Object.defineProperty(y,"Script",{enumerable:!0,get:function(){return a.Script}});var v={},w=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t),Object.defineProperty(e,i,{enumerable:!0,get:function(){return n[t]}})}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),b=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||w(n,e,t)};Object.defineProperty(v,"__esModule",{value:!0}),v.ChatContext=void 0,Object.defineProperty(v,"ChatContext",{enumerable:!0,get:function(){return i.ChatContext}}),b(p,v),b(h,v),b(y,v);var O={},_=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t),Object.defineProperty(e,i,{enumerable:!0,get:function(){return n[t]}})}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),C=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||_(n,e,t)};Object.defineProperty(O,"__esModule",{value:!0}),O.defineCommand=O.createScript=void 0,Object.defineProperty(O,"createScript",{enumerable:!0,get:function(){return a.createScript}}),Object.defineProperty(O,"defineCommand",{enumerable:!0,get:function(){return f.defineCommand}}),C(v,O);var g={};Object.defineProperty(g,"__esModule",{value:!0}),g.Colors=g.DEFAULT_OPTIONS=void 0,g.DEFAULT_OPTIONS={textColor:"#ffffff",visibilityTime:5e3,alertElement:"#curser"},function(e){e.WHITE="#FFFFFF",e.SILVER="#C0C0C0",e.GRAY="#808080",e.GREY="#808080",e.BLACK="#000000",e.RED="#FF0000",e.MAROON="#800000",e.YELLOW="#FFF000",e.OLIVE="#808000",e.LIME="#00FF00",e.GREEN="#008000",e.AQUA="#00FFFF",e.TEAL="#008080",e.BLUE="#0000FF",e.NAVY="#000080",e.FUCHSIA="#FF00FF",e.PURPLE="#800080"}(g.Colors||(g.Colors={}));var N={},S=this&&this.__assign||function(){return(S=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};Object.defineProperty(N,"__esModule",{value:!0}),N.useAlert=void 0,N.useAlert=function(e,n){n=S(S({},g.DEFAULT_OPTIONS),n);var t=document.querySelector(n.alertElement);n.textColor&&(t.style.color=n.textColor),t.style.fontSize="24px",t.textContent=e,t.style.display="block",setTimeout((function(){t.style.display="none"}),n.visibilityTime)};var F={};Object.defineProperty(F,"__esModule",{value:!0});var P={},j=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t),Object.defineProperty(e,i,{enumerable:!0,get:function(){return n[t]}})}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),M=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||j(n,e,t)};Object.defineProperty(P,"__esModule",{value:!0}),M(F,P);var A={},E=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t),Object.defineProperty(e,i,{enumerable:!0,get:function(){return n[t]}})}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),L=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||E(n,e,t)};Object.defineProperty(A,"__esModule",{value:!0}),A.Colors=A.useAlert=void 0,Object.defineProperty(A,"useAlert",{enumerable:!0,get:function(){return N.useAlert}}),L(P,A),Object.defineProperty(A,"Colors",{enumerable:!0,get:function(){return g.Colors}});const{defineCommand:T}=O,{useAlert:x,Colors:k}=A,D=[{displayName:"Dark Theme",name:"darktheme",function:window.setDark,id:"cDark"},{displayName:"Fancy Grid",name:"fancygrid",function:window.setFancyGrid,id:"cFancyGrid"},{displayName:"Section Grid",name:"sectiongrid",function:window.setSectionGrid,id:"cSectionGrid"},{displayName:"Gridlines",name:"gridlines",function:window.setGrid,id:"cGrid"},{displayName:"Skins",name:"skins",function:window.setSkins,id:"cSkins"},{displayName:"Wearables",name:"wearables",function:window.setWearables,id:"cWearables"},{displayName:"Show Names",name:"names",function:window.setNames,id:"cNames"},{displayName:"Minion Names",name:"minionnames",function:window.setMinionNames,id:"cMinionNames"},{displayName:"Large Names",name:"largenames",function:window.setLargeNames,id:"cLargeNames"},{displayName:"Name Outlines",name:"nameoutlines",function:window.setNameOutlines,id:"cNameOutlines"},{displayName:"Show Mass",name:"mass",function:window.setMass,id:"cMass"},{displayName:"Show Food",name:"food",function:window.setFood,id:"cFood"},{displayName:"Cell Animations",name:"cellanimations",function:window.setCellAnimations,id:"cCellAnimations"},{displayName:"Skin Animations",name:"skinanimations",function:window.setSkinAnimations,id:"cSkinAnimations"},{displayName:"Map Border",name:"mapborder",function:window.setMapBorder,id:"cMapBorder"},{displayName:"Sounds",name:"sounds",function:window.setSounds,id:"cSounds"},{displayName:"Infinite Zoom",name:"infinitezoom",function:window.setZoom,id:"cZoom"},{displayName:"Fixed Zoom",name:"fixedzoom",function:window.setFixedZoom,id:"cFixedZoom"},{displayName:"Slow Motion",name:"slowmotion",function:window.setSlowMotion,id:"cSlowMotion"},{displayName:"Minion Panel",name:"minionpanel",function:window.setMinionUi,id:"cMinionUi"},{displayName:"Leaderboard",name:"leaderboard",function:window.setLeaderboard,id:"cLeaderboard"},{displayName:"Chat",name:"chat",function:window.setChat,id:"cChat"},{displayName:"Minimap",name:"minimap",function:window.setMinimap,id:"cMinimap"},{displayName:"FPS / Ping / Stats",name:"fps",function:window.setFPS,id:"cFPS"},{displayName:"Cell Colors",name:"colors",function:window.setColors,id:"cColors"},{displayName:"Cell Borders",name:"cellborders",function:window.setCellBorders,id:"cCellBorders"},{displayName:"Cell Spikes",name:"cellspikes",function:window.setCellSpikes,id:"cCellSpikes"},{displayName:"Classic Virus Look",name:"classicvirus",function:window.setClassicViruses,id:"cClassicViruses"},{displayName:"Polygon Shapes",name:"polygonshapes",function:window.setPolygonShapes,id:"cPolygonShapes"},{displayName:"Line Shapes",name:"lineshapes",function:window.setLineShapes,id:"cLineShapes"},{displayName:"Bubble Cells",name:"bubblecells",function:window.setBubbleCells,id:"cBubbleCells"}];var I=[T({name:"setting",aliases:["s"],run:(e,n,t)=>{if(1==t.length){const e=D.find(e=>!!e&&e.name==t[0]);if(!e)return void x(`No setting found with name "${t[0]}"`,{textColor:k.RED});const{displayName:n,id:i}=e,o=document.getElementById(i);x(`The setting "${n}" is turned ${o.checked?"on":"off"}`,{textColor:o.checked?k.LIME:k.RED})}if(2==t.length&&("on"==t[1]||"off"==t[1])){const e="on"===t[1],n=D.find(e=>!!e&&e.name==t[0]);if(!n)return void x(`No setting found with name "${t[0]}"`,{textColor:k.RED});const{displayName:i,function:o,id:a}=n,r=document.getElementById(a);o(e),r.checked=e,x(`The setting "${i}" has been turned ${e?"on":"off"}`,{textColor:e?k.LIME:k.RED})}}})];const{createScript:B}=O,{name:R,version:U,description:G,author:W}={name:"agma-chat-command-settings",version:"2.1.0",description:"Configure your settings using the chat.",author:"CodingWithNuke"},$=B({name:R,version:U,description:G,author:W},{chatElementSelector:"#chtbox"});I.forEach(e=>$.command(e.name,e))}();