auto-champion-select 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,15 +11,14 @@
11
11
  Accept queue, pick and ban champions automatically. <br>
12
12
  This is my first project using JavaScript :)
13
13
 
14
- <img src="https://i.imgur.com/Ovy1gGw.png" width="700" alt="Plugin preview">
14
+ <img src="https://i.imgur.com/4jPzqIg.jpeg" width="700" alt="Plugin preview">
15
15
 
16
16
  </div>
17
17
  <br>
18
18
 
19
19
  ## 📍 What's new
20
20
 
21
- - Accept: automatically accepts matches (ready check)
22
- - CommandBar: use `CTRL + K` to turn auto pick/ban off/on
21
+ - Filter champions
23
22
 
24
23
  ## Dependencies
25
24
 
package/dist/index.js CHANGED
@@ -4,10 +4,10 @@
4
4
  * @name auto-champion-select
5
5
  * @link https://github.com/controlado/auto-champion-select#readme
6
6
  * @description Pick or ban automatically! 🐧
7
- * @version 1.6.0
7
+ * @version 1.6.2
8
8
  * @license GPL-3.0-or-later
9
9
  */
10
- import{sleep as u,request as c,linkEndpoint as S}from"https://cdn.jsdelivr.net/npm/balaclava-utils@latest";const T={enabled:!1},B={enabled:!1,force:!1,champions:[21,21]},F={enabled:!1,force:!1,champions:[21,21]},p={controladoAutoAccept:T,controladoPick:B,controladoBan:F};class I{constructor(){this.session=null,this.actions=null,this.localPlayerCellId=null,this.teamIntents=null,this.allPicks=null,this.allBans=null,this.mounted=!1,this.watch()}mount(){this.mounted=!0}unmount(){this.mounted=!1}async watch(){for(;;)this.mounted&&(await this.updateProperties(),await this.task()),await u(300)}async updateProperties(){const e=await c("GET","/lol-champ-select/v1/session");this.session=await e.json(),this.actions=this.session.actions,this.localPlayerCellId=this.session.localPlayerCellId,this.allPicks=[...this.session.myTeam,...this.session.theirTeam],this.allBans=[...this.session.bans.myTeamBans,...this.session.bans.theirTeamBans],this.teamIntents=this.session.myTeam.map(t=>t.championPickIntent)}async task(){const e=DataStore.get("controladoPick")||p.controladoPick,t=DataStore.get("controladoBan")||p.controladoBan;if(!e.enabled&&!t.enabled)return;const o=this.getLocalPlayerSubActions();if(o.length===0){console.debug("auto-champion-select: No local player sub actions found, skipping..."),this.unmount();return}for(const n of o){const i=n.type==="pick"?e:t;if(i.enabled)for(const a of i.champions){if(this.allBans.some(l=>l==a)){console.debug(`auto-champion-select: Banning ${a} but it's already banned, skipping...`);continue}if(n.type==="ban"&&this.teamIntents.some(l=>l==a))if(i.force===!0)console.debug(`auto-champion-select: Banning ${a} but it's already picked, forcing...`);else{console.debug(`auto-champion-select: Banning ${a} but it's already picked, skipping...`);continue}if(n.type==="pick"&&this.allPicks.some(l=>l.championId==a))if(i.force===!0)console.debug(`auto-champion-select: Picking ${a} but it's already picked, forcing...`);else{console.debug(`auto-champion-select: Picking ${a} but it's already picked, skipping...`);continue}if(console.debug(`auto-champion-select: Trying to ${n.type} ${a}...`),(await this.selectChampion(n.id,a)).ok)break;return}}}getLocalPlayerSubActions(){return this.actions.flat().filter(e=>e.actorCellId===this.localPlayerCellId&&e.completed===!1).sort((e,t)=>{const o=e.type==="pick"?0:1,n=t.type==="pick"?0:1;return o-n})}selectChampion(e,t){const o=`/lol-champ-select/v1/session/actions/${e}`;return c("PATCH",o,{body:{championId:t,completed:!0}})}}class m{constructor(e,t,o,n){this.element=document.createElement("lol-uikit-framed-dropdown"),this.element.classList.add("dropdown-champions-default"),this.element.classList.add("dropdown-drop-up"),this.text=e,this.config=null,this.configKey=t,this.configIndex=o,this.championsFunction=n,this.champions=null}async setup(){this.champions=await this.championsFunction(),this.config=DataStore.get(this.configKey)||p[this.configKey],this.champions.some(t=>this.config.champions[this.configIndex]===t.id)||(this.config.champions[this.configIndex]=this.champions[0].id,DataStore.set(this.configKey,this.config));const e=[];for(const t of this.champions){if(e.includes(t.name))continue;e.push(t.name);const o=this.getNewOption(t);this.element.appendChild(o)}this.shadowRoot(t=>{if(!t.querySelector("#controlado-placeholder")){const o=t.querySelector(".ui-dropdown-current");o.style="display: flex; justify-content: space-between;";const n=this.getNewPlaceholder();o.appendChild(n)}}),this.applyShadowStyles()}getNewOption(e){const t=document.createElement("lol-uikit-dropdown-option");return t.setAttribute("slot","lol-uikit-dropdown-option"),t.addEventListener("click",()=>{this.config.champions[this.configIndex]=e.id,DataStore.set(this.configKey,this.config),console.debug(this.configKey,DataStore.get(this.configKey)),this.shadowRoot(o=>{const n=o.querySelector("#controlado-search");n&&(n.value="",this.filterOptions(""));const i=o.querySelector(".controlado-filter-icon--trash");i&&i.classList.remove("controlado-filter-icon--trash")})}),this.config.champions[this.configIndex]===e.id&&t.setAttribute("selected","true"),t.innerText=e.name,t}getNewPlaceholder(){const e=document.createElement("div");e.classList.add("controlado-tag","controlado-tag--search"),e.id="controlado-placeholder";const t=document.createElement("input");t.classList.add("controlado-filter-input"),t.id="controlado-search",t.type="text",t.placeholder=this.text;const o=document.createElement("span");return o.classList.add("controlado-filter-icon"),o.addEventListener("click",n=>{o.classList.contains("controlado-filter-icon--trash")&&(t.value="",this.filterOptions(""),o.classList.toggle("controlado-filter-icon--trash",!1))}),t.addEventListener("input",n=>{this.ensureIsOpened(),this.filterOptions(n.target.value),o.classList.toggle("controlado-filter-icon--trash",!!n.target.value)}),["pointerdown","click"].forEach(n=>{e.addEventListener(n,i=>i.stopPropagation()),o.addEventListener(n,i=>i.stopPropagation())}),["pointerdown","focusin"].forEach(n=>{t.addEventListener(n,i=>i.stopPropagation(),!0)}),e.appendChild(o),e.appendChild(t),e}filterOptions(e){this.element.querySelectorAll("lol-uikit-dropdown-option").forEach(o=>{o.innerText.toLowerCase().includes(e.toLowerCase())?o.style.display="":o.style.display="none"})}refresh(){this.element.innerHTML="",this.setup()}isOpen(){return this.element.classList.contains("active")}ensureIsOpened(){this.isOpen()||this.shadowRoot(e=>{const t=e.querySelector(".ui-dropdown-current");t&&t.click()})}shadowRoot(e){const t=this.element.shadowRoot;t&&e(t)}applyShadowStyles(){this.shadowRoot(e=>{this.injectTagStyles(e);const t=e.querySelector(".ui-dropdown-current");t&&(t.style.paddingRight="28px");const o=e.querySelector(".ui-dropdown-options-container");o&&(o.style.top="auto",o.style.bottom="100%",o.style.transformOrigin="bottom",o.style.transform="translateY(0)");const n=e.querySelector("lol-uikit-scrollable");n&&(n.style.maxHeight="250px")})}injectTagStyles(e){const t=document.createElement("style");t.dataset.controlado="dropdown-tags",t.textContent=`
10
+ import{sleep as u,request as c,linkEndpoint as S}from"https://cdn.jsdelivr.net/npm/balaclava-utils@latest";const I={enabled:!1},L={enabled:!1,force:!1,champions:[21,21]},T={enabled:!1,force:!1,champions:[21,21]},p={controladoAutoAccept:I,controladoPick:L,controladoBan:T};class B{constructor(){this.session=null,this.actions=null,this.localPlayerCellId=null,this.teamIntents=null,this.allPicks=null,this.allBans=null,this.mounted=!1,this.watch()}mount(){this.mounted=!0}unmount(){this.mounted=!1}async watch(){for(;;)this.mounted&&(await this.updateProperties(),await this.task()),await u(300)}async updateProperties(){const e=await c("GET","/lol-champ-select/v1/session");this.session=await e.json(),this.actions=this.session.actions,this.localPlayerCellId=this.session.localPlayerCellId,this.allPicks=[...this.session.myTeam,...this.session.theirTeam],this.allBans=[...this.session.bans.myTeamBans,...this.session.bans.theirTeamBans],this.teamIntents=this.session.myTeam.map(t=>t.championPickIntent)}async task(){const e=DataStore.get("controladoPick")||p.controladoPick,t=DataStore.get("controladoBan")||p.controladoBan;if(!e.enabled&&!t.enabled)return;const o=this.getLocalPlayerSubActions();if(o.length===0){console.debug("auto-champion-select: No local player sub actions found, skipping..."),this.unmount();return}for(const n of o){const i=n.type==="pick"?e:t;if(i.enabled)for(const a of i.champions){if(this.allBans.some(l=>l==a)){console.debug(`auto-champion-select: Banning ${a} but it's already banned, skipping...`);continue}if(n.type==="ban"&&this.teamIntents.some(l=>l==a))if(i.force===!0)console.debug(`auto-champion-select: Banning ${a} but it's already picked, forcing...`);else{console.debug(`auto-champion-select: Banning ${a} but it's already picked, skipping...`);continue}if(n.type==="pick"&&this.allPicks.some(l=>l.championId==a))if(i.force===!0)console.debug(`auto-champion-select: Picking ${a} but it's already picked, forcing...`);else{console.debug(`auto-champion-select: Picking ${a} but it's already picked, skipping...`);continue}if(console.debug(`auto-champion-select: Trying to ${n.type} ${a}...`),(await this.selectChampion(n.id,a)).ok)break;return}}}getLocalPlayerSubActions(){return this.actions.flat().filter(e=>e.actorCellId===this.localPlayerCellId&&e.completed===!1).sort((e,t)=>{const o=e.type==="pick"?0:1,n=t.type==="pick"?0:1;return o-n})}selectChampion(e,t){const o=`/lol-champ-select/v1/session/actions/${e}`;return c("PATCH",o,{body:{championId:t,completed:!0}})}}class f{constructor(e,t,o,n){this.element=document.createElement("lol-uikit-framed-dropdown"),this.element.classList.add("dropdown-champions-default"),this.element.classList.add("dropdown-drop-up"),this.text=e,this.config=null,this.configKey=t,this.configIndex=o,this.championsFunction=n,this.champions=null,this.setupInFlight=null,this.setupPending=!1}async setup(){return this.setupPending=!0,this.setupInFlight||(this.setupInFlight=this.runSetupLoop()),this.setupInFlight}async runSetupLoop(){try{for(;this.setupPending;)this.setupPending=!1,await this.performSetup()}finally{this.setupInFlight=null}if(this.setupPending)return this.setup()}async performSetup(){this.champions=await this.championsFunction(),this.config=DataStore.get(this.configKey)||p[this.configKey],this.champions.some(t=>this.config.champions[this.configIndex]===t.id)||(this.config.champions[this.configIndex]=this.champions[0].id,DataStore.set(this.configKey,this.config)),this.element.replaceChildren();const e=new Set;for(const t of this.champions){if(e.has(t.name))continue;const o=this.getNewOption(t);this.element.appendChild(o),e.add(t.name)}this.shadowRoot(t=>{if(!t.querySelector("#controlado-placeholder")){const o=t.querySelector(".ui-dropdown-current");o.style="display: flex; justify-content: space-between;";const n=this.getNewPlaceholder();o.appendChild(n)}}),this.applyShadowStyles()}getNewOption(e){const t=document.createElement("lol-uikit-dropdown-option");return t.setAttribute("slot","lol-uikit-dropdown-option"),t.addEventListener("click",()=>{this.config.champions[this.configIndex]=e.id,DataStore.set(this.configKey,this.config),console.debug(this.configKey,DataStore.get(this.configKey)),this.shadowRoot(o=>{const n=o.querySelector("#controlado-search");n&&(n.value="",this.filterOptions(""));const i=o.querySelector(".controlado-filter-icon--trash");i&&i.classList.remove("controlado-filter-icon--trash")})}),this.config.champions[this.configIndex]===e.id&&t.setAttribute("selected","true"),t.innerText=e.name,t}getNewPlaceholder(){const e=document.createElement("div");e.classList.add("controlado-tag","controlado-tag--search"),e.id="controlado-placeholder";const t=document.createElement("input");t.classList.add("controlado-filter-input"),t.id="controlado-search",t.type="text",t.placeholder=this.text;const o=document.createElement("span");return o.classList.add("controlado-filter-icon"),o.addEventListener("click",n=>{o.classList.contains("controlado-filter-icon--trash")&&(t.value="",this.filterOptions(""),o.classList.toggle("controlado-filter-icon--trash",!1))}),t.addEventListener("input",n=>{this.ensureIsOpened(),this.filterOptions(n.target.value),o.classList.toggle("controlado-filter-icon--trash",!!n.target.value)}),["pointerdown","click"].forEach(n=>{e.addEventListener(n,i=>i.stopPropagation()),o.addEventListener(n,i=>i.stopPropagation())}),["pointerdown","focusin"].forEach(n=>{t.addEventListener(n,i=>i.stopPropagation(),!0)}),e.appendChild(o),e.appendChild(t),e}filterOptions(e){this.element.querySelectorAll("lol-uikit-dropdown-option").forEach(o=>{o.innerText.toLowerCase().includes(e.toLowerCase())?o.style.display="":o.style.display="none"})}refresh(){return this.setup()}isOpen(){return this.element.classList.contains("active")}ensureIsOpened(){this.isOpen()||this.shadowRoot(e=>{const t=e.querySelector(".ui-dropdown-current");t&&t.click()})}shadowRoot(e){const t=this.element.shadowRoot;t&&e(t)}applyShadowStyles(){this.shadowRoot(e=>{this.injectTagStyles(e);const t=e.querySelector(".ui-dropdown-current");t&&(t.style.paddingRight="28px");const o=e.querySelector(".ui-dropdown-options-container");o&&(o.style.top="auto",o.style.bottom="100%",o.style.transformOrigin="bottom",o.style.transform="translateY(0)");const n=e.querySelector("lol-uikit-scrollable");n&&(n.style.maxHeight="250px")})}injectTagStyles(e){if(e.querySelector("style[data-controlado='dropdown-tags']"))return;const t=document.createElement("style");t.dataset.controlado="dropdown-tags",t.textContent=`
11
11
  .controlado-filter-icon {
12
12
  cursor: default;
13
13
  display: inline-block;
@@ -64,4 +64,4 @@ import{sleep as u,request as c,linkEndpoint as S}from"https://cdn.jsdelivr.net/n
64
64
  text-transform: none;
65
65
  font-weight: 500;
66
66
  }
67
- `,e.appendChild(t)}}class b{constructor(e,t){this.element=document.createElement("lol-uikit-radio-input-option"),this.element.classList.add("lol-settings-voice-input-mode-option","auto-select-checkbox"),this.element.innerText=e,this.config=null,this.configKey=t}setup(){this.config=DataStore.get(this.configKey)||p[this.configKey],this.config.enabled&&this.element.setAttribute("selected","true"),this.element.addEventListener("click",()=>this.toggle())}toggle(){return console.debug("auto-champion-select: Toggling",this.configKey),this.config.enabled=!this.config.enabled,DataStore.set(this.configKey,this.config),this.element.toggleAttribute("selected"),this.config.enabled}}class O{constructor(e,...t){this.element=document.createElement("lol-social-roster-group"),this.element.addEventListener("post-render",()=>this.onPostRender()),this.element.addEventListener("click",()=>this.onClick()),this.label=e,this.hiddableElements=t,this.waitRender()}waitRender(){new MutationObserver((e,t)=>{if(this.element.querySelector("span")){const o=new Event("post-render");this.element.dispatchEvent(o),t.disconnect()}}).observe(this.element,{childList:!0})}onPostRender(){this.element.querySelector("span").innerText=this.label,this.element.querySelector(".group-header").removeAttribute("graggable")}onClick(){this.hiddableElements.forEach(e=>e.classList.toggle("hidden")),this.element.querySelector(".arrow").toggleAttribute("open")}}const r="Balaclava: Auto Champion Select";class k{constructor(e,t,o,n,i,a,y){this.id=e,this.name=t,this.legend=o,this.tags=n,this.group=i,this.perform=this.perform.bind(this),this.callback=a,this.toasts=y}perform(){if(typeof this.callback.then=="function")return Toast.promise(this.callback,{loading:this.toasts.loading,success:this.toasts.success,error:this.toasts.error});try{const e=this.callback();Toast.success(this.toasts.success||(e?this.toasts.on:this.toasts.off))}catch(e){Toast.error(this.toasts.error),console.error(e)}}}class v extends k{constructor(e,t,o){super(`${t}Switch`,()=>{var n;return`Auto ${e} [${(n=DataStore.get(t))!=null&&n.enabled?"ON":"OFF"}]`},()=>{var n;return(n=DataStore.get(t))!=null&&n.enabled?"Turn OFF":"Turn ON"},[r,t,"switch"],r,o,{on:`Auto ${e} is ON!`,off:`Auto ${e} is OFF!`,error:`Failed to toggle Auto ${e}. Check console.`})}}class E extends k{constructor(e,t){super(`${t}ForceSwitch`,()=>{var o;return`Force ${e} [${(o=DataStore.get(t))!=null&&o.force?"ON":"OFF"}]`},()=>`Ignore team intent and force ${e} the selected champion`,[r,t,"force","switch"],r,()=>this.switchDataStore(t),{on:`Force ${e} is ON!`,off:`Force ${e} is OFF!`,error:`Failed to toggle Force ${e}. Check console.`})}switchDataStore(e){const t=DataStore.get(e);return t.force=!t.force,DataStore.set(e,t),t.force}}class R extends k{constructor(e){super("RefreshDropdowns",()=>"Refresh Dropdowns",()=>"Normally dropdowns refresh automatically...",[r,"refresh"],r,()=>this.refreshDropdowns(e),{success:"Refreshed Dropdowns!",error:"Failed to refresh Dropdowns. Check console."})}refreshDropdowns(e){for(let t of e)t.refresh()}}class $ extends v{constructor(e){super("Pick","controladoPick",e)}}class q extends v{constructor(e){super("Ban","controladoBan",e)}}class N extends E{constructor(){super("Pick","controladoPick")}}class j extends E{constructor(){super("Ban","controladoBan")}}function G(s){for(let e of s)CommandBar.addAction(e)}const K="1.6.0";const x=new I,w=new b("Accept","controladoAutoAccept"),f=new b("Pick","controladoPick"),d=new m("1st pick","controladoPick",0,D),h=new m("2nd pick","controladoPick",1,D),g=new b("Ban","controladoBan"),C=new m("1st ban","controladoBan",0,L),P=new m("2nd ban","controladoBan",1,L);function A(){return document.querySelector(".lol-social-roster")}async function D(){let s=await c("GET","/lol-champions/v1/owned-champions-minimal");for(;!s.ok;)console.debug("auto-champion-select(owned-champions-minimal): Retrying..."),s=await c("GET","/lol-champions/v1/owned-champions-minimal"),await u(1e3);const e=await s.json();return e.sort((t,o)=>t.name.localeCompare(o.name)),e}async function L(){const e=await(await c("GET","/lol-game-data/assets/v1/champion-summary.json")).json();return e.sort((t,o)=>t.name.localeCompare(o.name)),e}async function z(){w.config.enabled===!0&&(console.debug("auto-champion-select(auto-accept): Ready check detected, accepting in 2 seconds..."),await u(2e3),await _())}async function _(){const s=await c("POST","/lol-matchmaking/v1/ready-check/accept");s.ok?console.debug("auto-champion-select(auto-accept): Accepted ready check"):console.error("auto-champion-select(auto-accept): Failed to accept ready check",s)}window.addEventListener("load",async()=>{let s=A();for(;!s;)await u(200),s=A();Promise.all([w.setup(),f.setup(),g.setup(),d.setup(),h.setup(),C.setup(),P.setup()]),G([new $(()=>f.toggle()),new q(()=>g.toggle()),new N,new j,new R([d,h])]),S("/lol-inventory/v1/wallet",n=>{n.eventType==="Update"&&(console.debug("auto-champion-select(wallet): Refreshing dropdowns..."),Promise.all([d.refresh(),h.refresh()]))}),S("/lol-gameflow/v1/gameflow-phase",n=>{n.data==="ReadyCheck"&&z(),n.data==="ChampSelect"?x.mount():x.unmount()});const e=document.createElement("div"),t=document.createElement("div");t.classList.add("auto-select-checkboxes-div"),t.append(w.element,f.element,g.element),e.append(d.element,h.element),e.append(C.element,P.element);const o=new O("Auto champion select",e,t);s.append(o.element,t,e),console.debug(`auto-champion-select(${K}): Report bugs to Balaclava#1912`)});
67
+ `,e.appendChild(t)}}class y{constructor(e,t){this.element=document.createElement("lol-uikit-radio-input-option"),this.element.classList.add("lol-settings-voice-input-mode-option","auto-select-checkbox"),this.element.innerText=e,this.config=null,this.configKey=t}setup(){this.config=DataStore.get(this.configKey)||p[this.configKey],this.config.enabled&&this.element.setAttribute("selected","true"),this.element.addEventListener("click",()=>this.toggle())}toggle(){return console.debug("auto-champion-select: Toggling",this.configKey),this.config.enabled=!this.config.enabled,DataStore.set(this.configKey,this.config),this.element.toggleAttribute("selected"),this.config.enabled}}class O{constructor(e,...t){this.element=document.createElement("lol-social-roster-group"),this.element.addEventListener("post-render",()=>this.onPostRender()),this.element.addEventListener("click",()=>this.onClick()),this.label=e,this.hiddableElements=t,this.waitRender()}waitRender(){new MutationObserver((e,t)=>{if(this.element.querySelector("span")){const o=new Event("post-render");this.element.dispatchEvent(o),t.disconnect()}}).observe(this.element,{childList:!0})}onPostRender(){this.element.querySelector("span").innerText=this.label,this.element.querySelector(".group-header").removeAttribute("graggable")}onClick(){this.hiddableElements.forEach(e=>e.classList.toggle("hidden")),this.element.querySelector(".arrow").toggleAttribute("open")}}const r="Balaclava: Auto Champion Select";class b{constructor(e,t,o,n,i,a,k){this.id=e,this.name=t,this.legend=o,this.tags=n,this.group=i,this.perform=this.perform.bind(this),this.callback=a,this.toasts=k}perform(){if(typeof this.callback.then=="function")return Toast.promise(this.callback,{loading:this.toasts.loading,success:this.toasts.success,error:this.toasts.error});try{const e=this.callback();Toast.success(this.toasts.success||(e?this.toasts.on:this.toasts.off))}catch(e){Toast.error(this.toasts.error),console.error(e)}}}class v extends b{constructor(e,t,o){super(`${t}Switch`,()=>{var n;return`Auto ${e} [${(n=DataStore.get(t))!=null&&n.enabled?"ON":"OFF"}]`},()=>{var n;return(n=DataStore.get(t))!=null&&n.enabled?"Turn OFF":"Turn ON"},[r,t,"switch"],r,o,{on:`Auto ${e} is ON!`,off:`Auto ${e} is OFF!`,error:`Failed to toggle Auto ${e}. Check console.`})}}class E extends b{constructor(e,t){super(`${t}ForceSwitch`,()=>{var o;return`Force ${e} [${(o=DataStore.get(t))!=null&&o.force?"ON":"OFF"}]`},()=>`Ignore team intent and force ${e} the selected champion`,[r,t,"force","switch"],r,()=>this.switchDataStore(t),{on:`Force ${e} is ON!`,off:`Force ${e} is OFF!`,error:`Failed to toggle Force ${e}. Check console.`})}switchDataStore(e){const t=DataStore.get(e);return t.force=!t.force,DataStore.set(e,t),t.force}}class R extends b{constructor(e){super("RefreshDropdowns",()=>"Refresh Dropdowns",()=>"Normally dropdowns refresh automatically...",[r,"refresh"],r,()=>this.refreshDropdowns(e),{success:"Refreshed Dropdowns!",error:"Failed to refresh Dropdowns. Check console."})}refreshDropdowns(e){for(let t of e)t.refresh()}}class $ extends v{constructor(e){super("Pick","controladoPick",e)}}class q extends v{constructor(e){super("Ban","controladoBan",e)}}class N extends E{constructor(){super("Pick","controladoPick")}}class j extends E{constructor(){super("Ban","controladoBan")}}function G(s){for(let e of s)CommandBar.addAction(e)}const K="1.6.2";const x=new B,w=new y("Accept","controladoAutoAccept"),m=new y("Pick","controladoPick"),d=new f("1st pick","controladoPick",0,D),h=new f("2nd pick","controladoPick",1,D),g=new y("Ban","controladoBan"),P=new f("1st ban","controladoBan",0,F),C=new f("2nd ban","controladoBan",1,F);function A(){return document.querySelector(".lol-social-roster")}async function D(){let s=await c("GET","/lol-champions/v1/owned-champions-minimal");for(;!s.ok;)console.debug("auto-champion-select(owned-champions-minimal): Retrying..."),s=await c("GET","/lol-champions/v1/owned-champions-minimal"),await u(1e3);const e=await s.json();return e.sort((t,o)=>t.name.localeCompare(o.name)),e}async function F(){const e=await(await c("GET","/lol-game-data/assets/v1/champion-summary.json")).json();return e.sort((t,o)=>t.name.localeCompare(o.name)),e}async function z(){w.config.enabled===!0&&(console.debug("auto-champion-select(auto-accept): Ready check detected, accepting in 2 seconds..."),await u(2e3),await _())}async function _(){const s=await c("POST","/lol-matchmaking/v1/ready-check/accept");s.ok?console.debug("auto-champion-select(auto-accept): Accepted ready check"):console.error("auto-champion-select(auto-accept): Failed to accept ready check",s)}window.addEventListener("load",async()=>{let s=A();for(;!s;)await u(200),s=A();const e=document.createElement("div"),t=document.createElement("div");t.classList.add("auto-select-checkboxes-div"),t.append(w.element,m.element,g.element),e.append(d.element,h.element),e.append(P.element,C.element);const o=new O("Auto champion select",e,t);s.append(o.element,t,e),await Promise.all([w.setup(),m.setup(),g.setup(),d.setup(),h.setup(),P.setup(),C.setup()]),G([new $(()=>m.toggle()),new q(()=>g.toggle()),new N,new j,new R([d,h])]),S("/lol-inventory/v1/wallet",async n=>{n.eventType==="Update"&&(console.debug("auto-champion-select(wallet): Refreshing dropdowns..."),await Promise.all([d.refresh(),h.refresh()]))}),S("/lol-gameflow/v1/gameflow-phase",n=>{n.data==="ReadyCheck"&&z(),n.data==="ChampSelect"?x.mount():x.unmount()}),console.debug(`auto-champion-select(${K}): Report bugs to Balaclava#1912`)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-champion-select",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "Pick or ban automatically! 🐧",
5
5
  "author": "balaclava",
6
6
  "repository": {