Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
[![CircleCI](https://circleci.com/gh/YarekTyshchenko/PMMGBeautifier.svg?style=shield)](https://circleci.com/gh/YarekTyshchenko/PMMGBeautifier)
Expand Down
30 changes: 30 additions & 0 deletions src/CXOS.ts
Original file line number Diff line number Diff line change
@@ -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);
}
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -15,7 +16,7 @@ const runner = new ModuleRunner([
new ShippingAds(),
new PostLM(),
new QueueLoad(),
]);
new CXOS(),]);
(function () {
runner.loop()
})();
18 changes: 18 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no way to add this without going through the script tag?

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 }));
}
118 changes: 118 additions & 0 deletions test.css
Original file line number Diff line number Diff line change
@@ -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;
}
Loading