auto-champion-select-fork 0.0.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 +44 -0
- package/README.md +23 -0
- package/dist/index.js +10 -0
- package/package.json +35 -0
package/README.br.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# `π§` Auto Champion Select <br>
|
|
4
|
+
|
|
5
|
+
[](https://wakatime.com/89c5e1c8-9e67-43ef-bd0e-3ff9a4fde5e2)
|
|
6
|
+
[](https://discordapp.com/users/854886148455399436) <br>
|
|
7
|
+

|
|
8
|
+
[](README.md)
|
|
9
|
+
[](README.br.md)
|
|
10
|
+
|
|
11
|
+
Aceite a fila, selecione e bana os campeΓ΅es automaticamente. <br>
|
|
12
|
+
Esse Γ© o meu primeiro projeto utilizando JavaScript :)
|
|
13
|
+
|
|
14
|
+
<img src="https://i.imgur.com/Ovy1gGw.png" width="700" alt="Plugin preview">
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
<br>
|
|
18
|
+
|
|
19
|
+
## π Novidades
|
|
20
|
+
|
|
21
|
+
- Accept: aceita, automaticamente, as partidas
|
|
22
|
+
- CommandBar: use `CTRL + K` para desligar/ligar o auto pick/ban
|
|
23
|
+
|
|
24
|
+
## DependΓͺncias
|
|
25
|
+
|
|
26
|
+
[Pengu Loader 1.0.5](https://github.com/PenguLoader/PenguLoader) (ou qualquer versΓ£o superior) <br>
|
|
27
|
+
[controladoUtils.js](https://github.com/controlado/pengu-plugins/blob/master/_controladoUtils.js) (incluso automaticamente)
|
|
28
|
+
|
|
29
|
+
## InstalaΓ§Γ£o
|
|
30
|
+
|
|
31
|
+
1. Baixe os arquivos atravΓ©s das releases [download direto](https://github.com/controlado/auto-champion-select/releases/latest/download/auto-champion-select.zip)
|
|
32
|
+
2. Extraia os arquivos para a pasta de plugins
|
|
33
|
+
|
|
34
|
+
A estrutura deve ser algo parecido com isso:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
π Pengu Loader
|
|
38
|
+
βββ π plugins
|
|
39
|
+
βββ π @default
|
|
40
|
+
βββ π auto-champion-select
|
|
41
|
+
βββ π README.md
|
|
42
|
+
βββ π README.br.md
|
|
43
|
+
βββ π index.js
|
|
44
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
# I DID NOT MAKE THIS THIS IS STRICTLY A FORK, ALL RIGHTS TO THE ORIGINAL AUTHOR.
|
|
3
|
+
## Dependencies
|
|
4
|
+
|
|
5
|
+
[Pengu Loader 1.0.5](https://github.com/PenguLoader/PenguLoader) (or any higher version) <br>
|
|
6
|
+
[controladoUtils.js](https://github.com/controlado/pengu-plugins) (automatically included)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
1. Download the files via the releases [direct download](https://github.com/controlado/auto-champion-select/releases/latest/download/auto-champion-select.zip)
|
|
11
|
+
2. Extract the files to the plugins folder
|
|
12
|
+
|
|
13
|
+
The structure should look something like this:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
π Pengu Loader
|
|
17
|
+
βββ π plugins
|
|
18
|
+
βββ π @default
|
|
19
|
+
βββ π auto-champion-select
|
|
20
|
+
βββ π README.md
|
|
21
|
+
βββ π README.br.md
|
|
22
|
+
βββ π index.js
|
|
23
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dropdown-champions-default{position:inherit;width:-webkit-fill-available}.auto-select-checkboxes-div{display:flex;border-top:thin solid #1e282d}.auto-select-checkbox{margin:auto}.auto-select-checkbox:last-child{margin-right:17px}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
/**
|
|
3
|
+
* @author balaclava
|
|
4
|
+
* @name auto-champion-select-fork
|
|
5
|
+
* @link https://github.com/controlado/auto-champion-select#readme
|
|
6
|
+
* @description Pick or ban automatically! π§
|
|
7
|
+
* @version 0.0.0.1
|
|
8
|
+
* @license GPL-3.0-or-later
|
|
9
|
+
*/
|
|
10
|
+
import{request as d,sleep as w,linkEndpoint as P}from"https://cdn.jsdelivr.net/npm/balaclava-utils@1.2.1/src/controladoUtils.min.js";import{sleep as $,request as S}from"https://cdn.skypack.dev/balaclava-utils@latest";const E={enabled:!1},I={enabled:!1,force:!1,champions:[21,21]},R={enabled:!1,force:!1,champions:[21,21]},p={controladoAutoAccept:E,controladoPick:I,controladoBan:R};class L{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 $(300)}async updateProperties(){const e=await S("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 n=this.getLocalPlayerSubActions();if(n.length===0){console.debug("auto-champion-select: No local player sub actions found, skipping..."),this.unmount();return}for(const s of n){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)break;return}}}getLocalPlayerSubActions(){return this.actions.flat().filter(e=>e.actorCellId===this.localPlayerCellId&&e.completed===!1).sort((e,t)=>{const n=e.type==="pick"?0:1,s=t.type==="pick"?0:1;return n-s})}selectChampion(e,t){const n=`/lol-champ-select/v1/session/actions/${e}`;return S("PATCH",n,{body:{championId:t,completed:!0}})}}class u{constructor(e,t,n,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=n,this.championsFunction=s,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 n=this.getNewOption(t);this.element.appendChild(n)}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 n=this.getNewPlaceholder();t.appendChild(n)}}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)||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 n=new Event("post-render");this.element.dispatchEvent(n),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 a="Balaclava: Auto Champion Select";class k{constructor(e,t,n,s,c,i,y){this.id=e,this.name=t,this.legend=n,this.tags=s,this.group=c,this.perform=this.perform.bind(this),this.callback=i,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 x extends k{constructor(e,t,n){super(`${t}Switch`,()=>`Auto ${e} [${DataStore.get(t)?.enabled?"ON":"OFF"}]`,()=>DataStore.get(t)?.enabled?"Turn OFF":"Turn ON",[a,t,"switch"],a,n,{on:`Auto ${e} is ON!`,off:`Auto ${e} is OFF!`,error:`Failed to toggle Auto ${e}. Check console.`})}}class F extends k{constructor(e,t){super(`${t}ForceSwitch`,()=>`Force ${e} [${DataStore.get(t)?.force?"ON":"OFF"}]`,()=>`Ignore team intent and force ${e} the selected champion`,[a,t,"force","switch"],a,()=>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 N extends k{constructor(e){super("RefreshDropdowns",()=>"Refresh Dropdowns",()=>"Normally dropdowns refresh automatically...",[a,"refresh"],a,()=>this.refreshDropdowns(e),{success:"Refreshed Dropdowns!",error:"Failed to refresh Dropdowns. Check console."})}refreshDropdowns(e){for(let t of e)t.refresh()}}class q extends x{constructor(e){super("Pick","controladoPick",e)}}class j extends x{constructor(e){super("Ban","controladoBan",e)}}class G extends F{constructor(){super("Pick","controladoPick")}}class K extends F{constructor(){super("Ban","controladoBan")}}function H(o){for(let e of o)CommandBar.addAction(e)}const M="0.0.0.1",C=new L,g=new b("Accept","controladoAutoAccept"),m=new b("Pick","controladoPick"),r=new u("1st pick","controladoPick",0,B),h=new u("2nd pick","controladoPick",1,B),f=new b("Ban","controladoBan"),A=new u("1st ban","controladoBan",0,T),v=new u("2nd ban","controladoBan",1,T);function D(){return document.querySelector(".lol-social-roster")}async function B(){let o=await d("GET","/lol-champions/v1/owned-champions-minimal");for(;!o.ok;)console.debug("auto-champion-select(owned-champions-minimal): Retrying..."),o=await d("GET","/lol-champions/v1/owned-champions-minimal"),await w(1e3);const e=await o.json();return e.sort((t,n)=>t.name.localeCompare(n.name)),e}async function T(){const e=await(await d("GET","/lol-game-data/assets/v1/champion-summary.json")).json();return e.sort((t,n)=>t.name.localeCompare(n.name)),e}async function U(){g.config.enabled===!0&&(console.debug("auto-champion-select(auto-accept): Ready check detected, accepting in 2 seconds..."),await w(2e3),await _())}async function _(){const o=await d("POST","/lol-matchmaking/v1/ready-check/accept");o.ok?console.debug("auto-champion-select(auto-accept): Accepted ready check"):console.error("auto-champion-select(auto-accept): Failed to accept ready check",o)}window.addEventListener("load",async()=>{let o=D();for(;!o;)await w(200),o=D();Promise.all([g.setup(),m.setup(),f.setup(),r.setup(),h.setup(),A.setup(),v.setup()]),H([new q(()=>m.toggle()),new j(()=>f.toggle()),new G,new K,new N([r,h])]),P("/lol-inventory/v1/wallet",s=>{s.eventType==="Update"&&(console.debug("auto-champion-select(wallet): Refreshing dropdowns..."),Promise.all([r.refresh(),h.refresh()]))}),P("/lol-gameflow/v1/gameflow-phase",s=>{s.data==="ReadyCheck"&&U(),s.data==="ChampSelect"?C.mount():C.unmount()});const e=document.createElement("div"),t=document.createElement("div");t.classList.add("auto-select-checkboxes-div"),t.append(g.element,m.element,f.element),e.append(r.element,h.element),e.append(A.element,v.element);const n=new O("Auto champion select",e,t);o.append(n.element,t,e),console.debug(`auto-champion-select(${M}): Report bugs to Balaclava#1912`)});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "auto-champion-select-fork",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Pick or ban automatically! π§",
|
|
5
|
+
"author": "balaclava",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/klwnny/auto-champion-select.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "GPL-3.0-or-later",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pengu-loader",
|
|
17
|
+
"league-client",
|
|
18
|
+
"league-of-legends",
|
|
19
|
+
"plugins",
|
|
20
|
+
"balaclava",
|
|
21
|
+
"controlado"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "vite build",
|
|
25
|
+
"watch": "vite build --watch --outDir ."
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/controlado/auto-champion-select/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/controlado/auto-champion-select#readme",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"vite": "^7.3.1",
|
|
33
|
+
"vite-plugin-css-injected-by-js": "^3.2.1"
|
|
34
|
+
}
|
|
35
|
+
}
|