diff --git a/README.md b/README.md index d5bf5dc..6b27976 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ * Show price per unit when posting local market ads * Change LM Post button to the type of ad * Calculate Queued production load in percentage +* In CXOS buffer open CXOB buffer when clicking ticker link instead of CXP # Installation [](https://circleci.com/gh/YarekTyshchenko/PMMGBeautifier) diff --git a/src/CXOS.ts b/src/CXOS.ts new file mode 100644 index 0000000..57999b8 --- /dev/null +++ b/src/CXOS.ts @@ -0,0 +1,30 @@ +import { openBuffer } from "./util"; + +const tag = "pb-cxos"; +export class CXOS { + cleanup() { + for (const elem of Array.from(document.getElementsByClassName(tag))) { + elem.classList.remove(tag); + elem.removeEventListener("click", openCXOB); + } + } + run() { + const elements = Array.from(document.querySelectorAll("table[class~='_2HAbDk9YexRt4S5-IhEbvT']")); + for (const table of elements) { + for (const row of Array.from(table.children[1].children)) { + const cell = row.children[2]; + const span: HTMLSpanElement = cell.children[0] as any + if (span) { + span.addEventListener("click", openCXOB); + span.classList.add(tag); + } + } + } + } +} + +function openCXOB(e: Event) { + e.stopImmediatePropagation(); + const span: HTMLSpanElement = e.target as any; + openBuffer("CXOB " + span.textContent); +} diff --git a/src/main.ts b/src/main.ts index 269850e..c6e77a6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import { ParseETAs } from "./ParseETAs"; import { PostLM } from "./PostLM"; import { ShippingAds } from "./ShippingAds"; import { QueueLoad } from "./QueueLoad"; +import { CXOS } from "./CXOS"; const runner = new ModuleRunner([ new LocalMarketAds(), @@ -15,7 +16,7 @@ const runner = new ModuleRunner([ new ShippingAds(), new PostLM(), new QueueLoad(), -]); + new CXOS(),]); (function () { runner.loop() })(); diff --git a/src/util.ts b/src/util.ts index 3d757ae..ea94cfc 100644 --- a/src/util.ts +++ b/src/util.ts @@ -69,3 +69,21 @@ export function toFixed(value: number, precision: number = 2) { const power = Math.pow(10, precision || 0); return Math.round(value * power) / power; } + +function loadScriptFromText(text: string) { + const scriptElement = document.createElement("script"); + scriptElement.textContent = text; + (document.head || document.documentElement).appendChild(scriptElement); +} + +const openBufferEventName = "pb-openbuffer" +loadScriptFromText(`document.addEventListener('${openBufferEventName}', function (e) { + const cmd = e.detail; + const root = document.getElementById('container'); + if (root) + root._reactRootContainer._internalRoot.current.child.child.child.child.child.child.child.child.child.child.child.child.pendingProps.openBuffer(cmd) +});`) + +export function openBuffer(cmd?: string) { + document.dispatchEvent(new CustomEvent(openBufferEventName, { detail: cmd })); +} diff --git a/test.css b/test.css new file mode 100644 index 0000000..14f8c04 --- /dev/null +++ b/test.css @@ -0,0 +1,118 @@ +._1JqhiJ8_SwKH8PRALcO9Hc { + color: #bbb; + position: relative; + flex-grow: 1; +} + +._1vWRpdI8cKNMPyOPnzlXgX { + font-size: 11px; + line-height: 1.1; +} + +._3ifriA33o8WAhdFSaIgqWi { + display: inline; + color: #3fa2de; + cursor: pointer; +} + +._1koW8Ep713S-bJq2JtDQbf { + display: inline-flex; + flex-direction: column; + width: 100%; + padding: 4px 8px; +} + +._1zR6iIrEu-_zsz_NztLd_d { + background-color: #222; + text-align: justify; + padding-bottom: 3px; +} + +._9OV6uxQlwxlq83OCpsGgY { + background-color: #23282b; +} + +._2NJYPo9yjhxjx33ER3xFk3 { + display: flex; + flex-direction: row; + padding: 0; + margin-bottom: 2px; + font-size: 11px; +} + +._9OV6uxQlwxlq83OCpsGgY label { + background-color: #3fa2de; +} + +._2NJYPo9yjhxjx33ER3xFk3 label { + display: inline-block; + min-width: 140px; + padding: 0 2px; + line-height: 17px; + color: #272727; + font-weight: bold; +} + +._3g19StcOClsv9eua4EHqhF:first-child { + margin-top: 2px; +} + +._3g19StcOClsv9eua4EHqhF { + display: flex; + flex-direction: column; +} + +._1W2XA0wtOCnijQzxBZNjQN { + display: inline-flex; + flex-direction: row; + justify-content: flex-end; +} +._1W2XA0wtOCnijQzxBZNjQN > div { + margin-right: 2px; + margin-left: 2px; + margin-bottom: 2px; + line-height: 28px; +} + +.fdpfT6y20U7LwZRHDYHvh { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 33px; + height: 33px; + background-color: #222; + text-align: center; + line-height: 12px !important; +} +._8ENerpubNQH-6T4gcbv3o { + float: left; + margin-right: 4px; +} +._1BIGnSPbvzDVBNLlwLm3GK { + font-weight: bold; + text-align: center; +} + +._3_fKwpMW5YuE8OY9dgTTUr { + position: absolute; + bottom: 0; + right: 0; + display: flex; + flex-direction: column; + justify-content: flex-end; + align-items: flex-end; +} + +._3ASaYtXQD9Z4Pxvf0cVnxI { + line-height: 0.9; + border-radius: 3px 0 0 0; + padding: 3px 3px 2px 4px; + color: #bbb; + background-color: #23282b; +} + +.rRkbQMZ3sqEwwoTeNKKbE { + font-size: 8px; + line-height: 1; +} diff --git a/test.html b/test.html index 4cd7d10..1bfa20a 100644 --- a/test.html +++ b/test.html @@ -1,1217 +1,1830 @@ + +
+ + + -| - | Fee | -Input | -Output | -Completion / Duration | -Status | -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Active | -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
-
-
-
- HCP
+
|
+
+ 15.00 CIS
+ FIO Corp - Proxion
+ |
+
+ 246
+ / 6
+ Water
+
+ |
+
+ 12 Protein-Rich Beans
+ |
+ 1 day 14h (07:21 +1d) + | +recurring + | ++ + | +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
+
+
+
+
+
+
+
+ NUT
+
+
+ |
+
+ 15.00 CIS
+ FIO Corp - Proxion
+ |
+
+ 246
+ / 1
+ Water
+
+ |
+
+ 12 Triglyceride Nuts
+ |
+ 1 day 14h (07:21 +1d) + | +recurring + | ++ + | +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
+
+
+
+
+
+
+
+ GRN
+
+
+ |
+
+ 15.00 CIS
+ FIO Corp - Proxion
+ |
+
+ 246
+ / 3
+ Water
+
+ |
+
+ 12 High-Carb Grains
+ |
+ 1 day 14h (07:21 +1d) + | +recurring + | ++ + | +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Transponder | -Name | -Cargo | -Status | -Fuel | -Location | -Destination | -ETA | -Command | -
|---|---|---|---|---|---|---|---|---|
| AVI-00DLP | -Springy Concrete | -- | -
- jumping
- |
- - | -- | -Benten - Katoa (XK-745b) | -11h 17m | -
-
-
-
-
-
-
- |
-
| AVI-00DLQ | -Dead Seal on a Ball | -- | stationary | -- | Benten - Katoa (XK-745b) | -- | - |
-
-
-
-
-
-
- |
-
| Transponder | +Name | +Cargo | +Status | +Fuel | +Location | +Destination | +ETA | +Command | +
|---|---|---|---|---|---|---|---|---|
| AVI-00DLP | +Springy Concrete | ++ + + | +
+ jumping
+ |
+ + + + | +-- | +Benten - Katoa (XK-745b) | +11h 17m | +
+
+
+
+
+
+
+ |
+
| AVI-00DLQ | +Dead Seal on a Ball | +
+
+
+ |
+ stationary | ++ + + | +Benten - Katoa (XK-745b) | ++ | + |
+
+
+
+
+
+
+ |
+
| - | Fee | -Input | -Output | -Completion / Duration | -Status | -- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Active | -|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
-
-
-
- O
+ Production Queue (PRODQ)+
|
+
+ 63.40 CIS
+ Mao-Kikowski Mercantile
+ |
+ + |
+ 80 Oxygen
+ |
+ 6 days 16h | ++ | + + | +|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
+
+
+
+ |
+ + | + | + | + | + | + | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | -Type | -Destination | -Duration | -Distance | -Consumption | -
|---|---|---|---|---|---|
| - | - | Daikoku - Proxion | -10h 13m | -
- 116,231,854 km11 parsecs
- |
-
- 147 units STL fuel38 units FTL fuel
- |
-
| 0 | -TO | -Benten - Katoa (orbit) | -4m 35s | -3,701 km | -
- 36 units STL fuel
- |
-
| 1 | -DEP | -Benten (orbit) | -2h 29m | -73,206,218 km | -
- 49 units STL fuel38 units FTL fuel
- |
-
| 2 | -JMP | -Daikoku (orbit) | -4h 30m | -11 parsecs | -
-
- |
-
| 3 | -APP | -Daikoku - Proxion (orbit) | -3h 5m | -43,017,631 km | -
- 23 units STL fuel
- |
-
| 4 | -LND | -Daikoku - Proxion | -4m 57s | -4,304 km | -
- 39 units STL fuel
- |
-
| # | +Type | +Destination | +Duration | +Distance | +Consumption | +
|---|---|---|---|---|---|
| + | + | Daikoku - Proxion | +10h 13m | +
+ 116,231,854 km11 parsecs
+ |
+
+ 147 units STL fuel38 units FTL fuel
+
+ |
+
| 0 | +TO | +Benten - Katoa (orbit) | +4m 35s | +3,701 km | +
+ 36 units STL fuel
+ |
+
| 1 | +DEP | +Benten (orbit) | +2h 29m | +73,206,218 km | +
+ 49 units STL fuel38 units FTL fuel
+
+ |
+
| 2 | +JMP | +Daikoku (orbit) | +4h 30m | +11 parsecs | +
+
+ |
+
| 3 | +APP | +Daikoku - Proxion (orbit) | +3h 5m | +43,017,631 km | +
+ 23 units STL fuel
+ |
+
| 4 | +LND | +Daikoku - Proxion | +4m 57s | +4,304 km | +
+ 39 units STL fuel
+ |
+