auto-champion-select 1.0.0 → 1.1.0

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.
@@ -6,7 +6,7 @@
6
6
  [![discord](https://img.shields.io/badge/Discord-%235865F2.svg?style=flat&logo=discord&logoColor=white&color=blue)](https://discordapp.com/users/854886148455399436) <br>
7
7
  ![languages](https://img.shields.io/badge/Documentation-gray)
8
8
  [![english](https://img.shields.io/badge/-English-blue)](README.md)
9
- [![português](https://img.shields.io/badge/-Português%20Brasileiro-blue)](README.BR.md)
9
+ [![português](https://img.shields.io/badge/-Português%20Brasileiro-blue)](README.br.md)
10
10
 
11
11
  Selecione e bana os campeões automaticamente. <br>
12
12
  Esse é o meu primeiro projeto utilizando JavaScript :)
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![discord](https://img.shields.io/badge/Discord-%235865F2.svg?style=flat&logo=discord&logoColor=white&color=blue)](https://discordapp.com/users/854886148455399436) <br>
7
7
  ![languages](https://img.shields.io/badge/Documentation-gray)
8
8
  [![english](https://img.shields.io/badge/-English-blue)](README.md)
9
- [![português](https://img.shields.io/badge/-Português%20Brasileiro-blue)](README.BR.md)
9
+ [![português](https://img.shields.io/badge/-Português%20Brasileiro-blue)](README.br.md)
10
10
 
11
11
  Pick and ban champions automatically. <br>
12
12
  This is my first project using JavaScript :)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-champion-select",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Pick or ban automatically! 🐧",
5
5
  "author": "balaclava",
6
6
  "repository": {
@@ -29,6 +29,7 @@
29
29
  },
30
30
  "homepage": "https://github.com/controlado/auto-champion-select#readme",
31
31
  "devDependencies": {
32
- "vite": "^4.4.6"
32
+ "vite": "^4.4.6",
33
+ "vite-plugin-css-injected-by-js": "^3.2.1"
33
34
  }
34
35
  }
package/dist/index.js DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * @author balaclava
3
- * @name auto-champion-select
4
- * @link https://github.com/controlado/auto-champion-select#readme
5
- * @description Pick or ban automatically! 🐧
6
- * @version 1.0.0
7
- * @license GPL-3.0-or-later
8
- */
9
- import{request as b,linkEndpoint as k,addRoutines as y,sleep as S}from"https://cdn.skypack.dev/balaclava-utils@latest";async function w(t,e,n=!0){const o=`/lol-champ-select/v1/session/actions/${t}`;return(await b("PATCH",o,{body:{completed:n,championId:e}})).ok}async function x(){return(await b("GET","/lol-champ-select/v1/session")).json()}async function D(){return(await b("GET","/lol-gameflow/v1/gameflow-phase")).json()}async function v(){const e=await(await b("GET","/lol-game-data/assets/v1/champion-summary.json")).json();return e.sort((n,o)=>n.name.localeCompare(o.name)),e}function A(t){const e=document.createElement("lol-uikit-framed-dropdown");return e.setAttribute("style","margin-bottom: 1.2px;"),e.id=t,e}function E(t){const e=document.createElement("lol-uikit-dropdown-option");return e.setAttribute("slot","lol-uikit-dropdown-option"),e.textContent=t,e}function T(t,e){const n=document.createElement("lol-uikit-radio-input-option");return n.setAttribute("style","margin-left: 16px; font-family: Arial;"),n.setAttribute("selected",e?"true":"false"),n.textContent=t,n}let h=null;const I={enabled:!1,champions:[429,136]},q={enabled:!1,force:!1,champions:[350,221]},B=async t=>{if(t.data==="ChampSelect")for(;await D()==="ChampSelect";){const e=await x();if(await P(e),e.timer.phase==="FINALIZATION")return;await S(200)}},P=async t=>{const{localPlayerCellId:e,actions:n,bans:o,myTeam:c,theirTeam:l}=t,p=[...o.myTeamBans,...o.theirTeamBans],m=[...c,...l],u=DataStore.get("pickChampion"),d=DataStore.get("banChampion");for(const a of n)for(const s of a)if(!(s.completed||s.actorCellId!=e)){if(s.type==="pick"&&u.enabled){for(const i of u.champions)if(!p.some(r=>r==i)&&!m.some(r=>r.championId==i)&&await w(s.id,i))return}if(s.type==="ban"&&d.enabled){for(const i of d.champions)if(!p.some(r=>r==i)&&!(!d.force&&c.some(r=>r.championPickIntent==i))){if(await w(s.id,i))return;break}}}};class f{constructor(e,n,o,c,l=!1){this.index=e,this.id=n,this.champions=o,this.selectedChampion=null,this.config=DataStore.get(this.id),this.element=A(this.id);for(const p of this.champions){const m=this.getOption(p);this.element.append(m)}l&&(this.element.style.filter="brightness(0.7)"),this.hoverText=this.element.shadowRoot.querySelector("div > dt > div"),this.element.onmouseenter=()=>{this.hoverText.textContent=c},this.element.onmouseleave=()=>{this.hoverText.textContent=this.selectedChampion}}getOption(e){const n=E(e.name);return n.onclick=()=>{this.config.champions[this.index]=e.id,this.selectedChampion=e.name,DataStore.set(this.id,this.config)},this.config.champions[this.index]==e.id&&(this.selectedChampion=e.name,n.setAttribute("selected","true")),n}}class C{constructor(e){this.element=document.createElement("div"),this.element.id=e}}class j{constructor(e){this.element=document.createElement("div"),this.element.className="alpha-version-panel",this.element.id=e}}class g{constructor(e,n){this.configKey=n,this.config=DataStore.get(this.configKey),this.element=T(e,this.config.enabled),this.element.onclick=()=>{this.config.enabled=!this.config.enabled,DataStore.set(this.configKey,this.config),this.config.enabled?this.element.setAttribute("selected","true"):this.element.removeAttribute("selected")}}}const G=()=>{const t=document.querySelector(".lol-social-lower-pane-container");if(!t||document.querySelector("#checkbox-container")||document.querySelector("#pick-dropdown-container")||document.querySelector("#ban-dropdown-container"))return;const e=new j("checkbox-container"),n=new C("pick-dropdown-container"),o=new C("ban-dropdown-container"),c=new g("Auto pick","pickChampion"),l=new g("Auto ban","banChampion"),p=new f(0,"pickChampion",h,"First pick option"),m=new f(1,"pickChampion",h,"Second pick option"),u=new f(0,"banChampion",h,"First ban option",!0),d=new f(1,"banChampion",h,"Second ban option",!0);e.element.append(c.element,l.element),n.element.append(p.element,m.element),o.element.append(u.element,d.element);const a=document.createElement("lol-social-roster-group");a.classList.add("group","group-label"),a.addEventListener("click",()=>{const i=a.nextElementSibling;i.style.display=i.style.display==="none"?"block":"none",a.querySelector(".arrow").toggleAttribute("open")});const s=document.createElement("div");s.append(e.element,n.element,o.element),t.append(a,s),a.querySelector("span").textContent="Auto pick/ban",a.querySelector(".group-header").removeAttribute("draggable")};window.addEventListener("load",async()=>{h=await v(),DataStore.has("pickChampion")||DataStore.set("pickChampion",I),DataStore.has("banChampion")||DataStore.set("banChampion",q),k("/lol-gameflow/v1/gameflow-phase",B),y(G),console.debug("auto-champion-select: Report bugs to Balaclava#1912")});