auto-champion-select 1.2.1 → 1.3.1
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.br.md +7 -2
- package/README.md +7 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.br.md
CHANGED
|
@@ -8,14 +8,19 @@
|
|
|
8
8
|
[](README.md)
|
|
9
9
|
[](README.br.md)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Aceite a fila, selecione e bana os campeões automaticamente. <br>
|
|
12
12
|
Esse é o meu primeiro projeto utilizando JavaScript :)
|
|
13
13
|
|
|
14
|
-
<img src="https://i.imgur.com/
|
|
14
|
+
<img src="https://i.imgur.com/Ovy1gGw.png" width="700" alt="Plugin preview">
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
<br>
|
|
18
18
|
|
|
19
|
+
## 📍 Novidades
|
|
20
|
+
|
|
21
|
+
- Accept: aceita, automaticamente, as partidas
|
|
22
|
+
- CommandBar: use `CTRL + K` para desligar/ligar o auto pick/ban
|
|
23
|
+
|
|
19
24
|
## Dependências
|
|
20
25
|
|
|
21
26
|
[Pengu Loader 1.0.5](https://github.com/PenguLoader/PenguLoader) (ou qualquer versão superior) <br>
|
package/README.md
CHANGED
|
@@ -8,14 +8,19 @@
|
|
|
8
8
|
[](README.md)
|
|
9
9
|
[](README.br.md)
|
|
10
10
|
|
|
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/
|
|
14
|
+
<img src="https://i.imgur.com/Ovy1gGw.png" width="700" alt="Plugin preview">
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
<br>
|
|
18
18
|
|
|
19
|
+
## 📍 What's new
|
|
20
|
+
|
|
21
|
+
- Accept: automatically accepts matches (ready check)
|
|
22
|
+
- CommandBar: use `CTRL + K` to turn auto pick/ban off/on
|
|
23
|
+
|
|
19
24
|
## Dependencies
|
|
20
25
|
|
|
21
26
|
[Pengu Loader 1.0.5](https://github.com/PenguLoader/PenguLoader) (or any higher version) <br>
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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.
|
|
7
|
+
* @version 1.3.1
|
|
8
8
|
* @license GPL-3.0-or-later
|
|
9
9
|
*/
|
|
10
|
-
import{sleep as d,request as
|
|
10
|
+
import{sleep as d,request as a,linkEndpoint as y}from"https://cdn.skypack.dev/balaclava-utils@latest";const E={enabled:!1},$={enabled:!1,force:!1,champions:[21,21]},D={enabled:!1,force:!1,champions:[21,21]},r={controladoAutoAccept:E,controladoPick:$,controladoBan:D};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 d(300)}async updateProperties(){const e=await a("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")||r.controladoPick,t=DataStore.get("controladoBan")||r.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 s of o){const c=s.type==="pick"?e:t;if(c.enabled)for(const i of c.champions){if(this.allBans.some(l=>l==i)){console.debug(`auto-champion-select: Banning ${i} but it's already banned, skipping...`);continue}if(s.type==="ban"&&this.teamIntents.some(l=>l==i))if(c.force===!0)console.debug(`auto-champion-select: Banning ${i} but it's already picked, forcing...`);else{console.debug(`auto-champion-select: Banning ${i} but it's already picked, skipping...`);continue}if(s.type==="pick"&&this.allPicks.some(l=>l.championId==i))if(c.force===!0)console.debug(`auto-champion-select: Picking ${i} but it's already picked, forcing...`);else{console.debug(`auto-champion-select: Picking ${i} but it's already picked, skipping...`);continue}if(console.debug(`auto-champion-select: Trying to ${s.type} ${i}...`),(await this.selectChampion(s.id,i)).ok){console.debug("auto-champion-select: OK!");return}}}}getLocalPlayerSubActions(){return this.actions.flat().filter(e=>e.actorCellId===this.localPlayerCellId&&e.completed===!1)}selectChampion(e,t){const o=`/lol-champ-select/v1/session/actions/${e}`;return a("PATCH",o,{body:{championId:t,completed:!0}})}}class u{constructor(e,t,o,s){this.element=document.createElement("lol-uikit-framed-dropdown"),this.element.classList.add("dropdown-champions-default"),this.text=e,this.config=null,this.configKey=t,this.configIndex=o,this.championsFunction=s,this.champions=null}async setup(){this.champions=await this.championsFunction(),this.config=DataStore.get(this.configKey)||r[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)}if(!this.element.shadowRoot.querySelector("#controlado-placeholder")){const t=this.element.shadowRoot.querySelector(".ui-dropdown-current");t.style="display: flex; justify-content: space-between;";const o=this.getNewPlaceholder();t.appendChild(o)}}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)}),this.config.champions[this.configIndex]===e.id&&t.setAttribute("selected","true"),t.innerText=e.name,t}getNewPlaceholder(){const e=document.createElement("div");return e.classList.add("ui-dropdown-current-content"),e.style="width: unset; overflow: visible;",e.id="controlado-placeholder",e.innerText=this.text,e}refresh(){this.element.innerHTML="",this.setup()}}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)||r[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 h="Balaclava: Auto Champion Select";class v{constructor(e,t,o,s,c,i,k){this.id=e,this.name=t,this.legend=o,this.tags=s,this.group=c,this.perform=this.perform.bind(this),this.callback=i,this.toasts=k}perform(){try{const e=this.callback();Toast.success(e?this.toasts.on:this.toasts.off)}catch(e){Toast.error(this.toasts.error),console.error(e)}}}class x extends v{constructor(e,t,o){super(`${t}Switch`,()=>{var s;return`Auto ${e} [${(s=DataStore.get(t))!=null&&s.enabled?"ON":"OFF"}]`},()=>{var s;return(s=DataStore.get(t))!=null&&s.enabled?"Turn OFF":"Turn ON"},[h,t,"switch"],h,o,{on:`Auto ${e} is ON`,off:`Auto ${e} is OFF`,error:`Failed to toggle Auto ${e}. Check console.`})}}class B extends v{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`,[h,t,"force","switch"],h,()=>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 L extends x{constructor(e){super("Pick","controladoPick",e)}}class R extends x{constructor(e){super("Ban","controladoBan",e)}}class N extends B{constructor(){super("Pick","controladoPick")}}class q extends B{constructor(){super("Ban","controladoBan")}}function j(n){for(let e of n)CommandBar.addAction(e)}const G="1.3.1";const S=new I,w=new b("Accept","controladoAutoAccept"),p=new b("Pick","controladoPick"),m=new u("1st pick","controladoPick",0,F),g=new u("2nd pick","controladoPick",1,F),f=new b("Ban","controladoBan"),A=new u("1st ban","controladoBan",0,T),P=new u("2nd ban","controladoBan",1,T);function C(){return document.querySelector("lol-social-roster.roster")}async function F(){let n=await a("GET","/lol-champions/v1/owned-champions-minimal");for(;!n.ok;)console.debug("auto-champion-select(owned-champions-minimal): Retrying..."),n=await a("GET","/lol-champions/v1/owned-champions-minimal"),await d(1e3);const e=await n.json();return e.sort((t,o)=>t.name.localeCompare(o.name)),e}async function T(){const e=await(await a("GET","/lol-game-data/assets/v1/champion-summary.json")).json();return e.sort((t,o)=>t.name.localeCompare(o.name)),e}async function K(){w.config.enabled===!0&&(console.debug("auto-champion-select(auto-accept): Ready check detected, accepting in 2 seconds..."),await d(2e3),await H())}async function H(){const n=await a("POST","/lol-matchmaking/v1/ready-check/accept");n.ok?console.debug("auto-champion-select(auto-accept): Accepted ready check"):console.error("auto-champion-select(auto-accept): Failed to accept ready check",n)}window.addEventListener("load",async()=>{let n=C();for(;!n;)await d(200),n=C();Promise.all([w.setup(),p.setup(),f.setup(),m.setup(),g.setup(),A.setup(),P.setup()]),j([new L(()=>p.toggle()),new R(()=>f.toggle()),new N,new q]),y("/lol-inventory/v1/wallet",s=>{s.eventType==="Update"&&(console.debug("auto-champion-select(wallet): Refreshing dropdowns..."),Promise.all([m.refresh(),g.refresh()]))}),y("/lol-gameflow/v1/gameflow-phase",s=>{s.data==="ReadyCheck"&&K(),s.data==="ChampSelect"?S.mount():S.unmount()});const e=document.createElement("div"),t=document.createElement("div");t.classList.add("auto-select-checkboxes-div"),t.append(w.element,p.element,f.element),e.append(m.element,g.element),e.append(A.element,P.element);const o=new O("Auto champion select",e,t);n.append(o.element,t,e),console.debug(`auto-champion-select(${G}): Report bugs to Balaclava#1912`)});
|