-
Notifications
You must be signed in to change notification settings - Fork 17
LM, CX, ETA - shortening, coloring, fixing, nicening #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 41 commits
523c0d2
ca08362
9873b26
8314fef
c4fc49a
a41423c
90357bc
bdd6d6b
61f9f1c
149877f
b572724
3e1ae72
f8cd860
c211cf7
c0bf1d9
a137c96
f33a529
4bb7243
728d18b
ab4cf65
4c4742d
7535b0d
5b3b71a
8d94265
9ce6b22
76b0070
fc7e945
17a540b
10ac685
326df0e
1246da7
3c8572e
68b1082
127cda3
6d8ae6a
5b7c51d
ba5e3ac
a12de43
ec2b3a2
557f491
3386e09
2d60efb
5ac9747
0bffb75
992668b
757d779
fa2599d
e8d96fc
84602cc
8abdbf6
0a2f82b
a53cb3d
cc05e8c
6e6d292
53c404a
5e8ca87
73ca3c5
8fb1103
f1f7567
290505c
2f47f87
7f412e3
c29e25f
7651ab2
3ad5d3c
690c7a9
add08e7
0604049
dbdc85a
fd343e7
31d0a08
17fba00
f692b45
4d68542
4fbc5de
5d961d4
bd5472c
eeb672c
76b427c
fcbd6a5
196b4e9
7a62f05
d7b6bfd
6b5e3bc
7b8b3da
59fcab7
7682e30
4c0659a
f271709
e54243b
e0b45f6
c70cb06
ad074aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| dist/main.js | ||
| node_modules | ||
|
|
||
| /.vs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| "manifest_version": 2, | ||
| "name": "PMMG Beautifier", | ||
| "description": "Improve and tweak the interface elements of PrUn website", | ||
| "version": "0.4.1", | ||
| "version": "0.4.1.1", | ||
|
||
| "icons": { | ||
| "128": "icon128.png" | ||
| }, | ||
|
|
@@ -18,5 +18,11 @@ | |
| "main.js" | ||
| ] | ||
| } | ||
| ] | ||
| ], | ||
| "applications": { | ||
| "gecko": { | ||
| "id": "[email protected]", | ||
| "update_url": "https://your_server_location_where_you_host_zips/updates.json" | ||
| } | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this section
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. already removed |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import { Selector } from "./Selector"; | ||
| import { genericCleanup, shorten, toFixed } from "./util"; | ||
|
|
||
| export class CXFX { | ||
| private tag = "pb-cx"; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All files should be indented with 2 spaces, not 4.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be fixed |
||
| cleanup() { | ||
| genericCleanup(this.tag); | ||
| } | ||
| run() { | ||
| // CXOB | ||
| const elements = document.querySelectorAll(Selector.CXOBTable + " > tbody > tr > td"); | ||
| for (let i = 0; i < elements.length; i++) { | ||
| const element = elements[i]; | ||
| const text = element.textContent; | ||
| const matches = text && text.match(/^NEO Charter Exploration Market Maker$/); | ||
|
||
| if (matches) { | ||
| element.textContent = shorten(text); | ||
| } | ||
| } | ||
|
|
||
| // CXOB + FXOB | ||
| const companies = Array.from(document.querySelectorAll(Selector.CXOBTable + " > tbody > tr > td > span")).concat(Array.from(document.querySelectorAll(Selector.FXOBTable + " > tbody > tr > td > span"))); | ||
| for (let i = 0; i < companies.length; i++) { | ||
| const element = companies[i]; | ||
| const text = element.textContent; | ||
| if (text!.length > 25) { | ||
| element.textContent = text!.substring(0, 23) + "\*"; | ||
| } | ||
| } | ||
|
|
||
| // CXOS | ||
| const orderCX = document.querySelectorAll(Selector.CXOrdersExchangeName); | ||
| for (let i = 0; i < orderCX.length; i++) { | ||
| const element = orderCX[i]; | ||
| const text = element.textContent; | ||
| const matches = text && text.match(/Station Commodity Exchange$/); | ||
| if (matches) { | ||
| element.textContent = shorten(text); | ||
| } | ||
| } | ||
|
|
||
| const orderAmountColumn = document.querySelectorAll(Selector.CXOrdersTable + " > thead > tr > th"); | ||
| for (let i = 0; i < orderAmountColumn.length; i++) { | ||
| const element = orderAmountColumn[i]; | ||
| const text = element.textContent; | ||
| const matches = text && text.match(/^Amount \(initial\)$/); | ||
| if (matches) { | ||
| element.textContent = "Amount \(i\)"; | ||
| } | ||
| } | ||
|
|
||
| const orderStatus = document.querySelectorAll(Selector.CXOrdersTable + " > tbody > tr > td:nth-of-type(7) > span"); | ||
| for (let i = 0; i < orderStatus.length; i++) { | ||
| orderStatus[i].childNodes[0].parentElement!.removeAttribute("style"); | ||
| if (orderStatus[i].textContent == "partially filled" || orderStatus[i].textContent == "part fill") { | ||
| orderStatus[i].textContent = "part fill"; | ||
| orderStatus[i].childNodes[0].parentElement!.style.color = "#d77342"; | ||
| } | ||
| } | ||
|
|
||
| workCXOSHeader(this.tag); | ||
| workCXOSRows(this.tag); | ||
| } | ||
| } | ||
|
|
||
| const hideMatNameColumn: boolean = true; | ||
| const addOrderValueColumn: boolean = true; | ||
|
|
||
| function workCXOSHeader(tag) { | ||
| const CXOSHeader = document.querySelector(Selector.CXOrdersTable + " > thead > tr")!; | ||
| if (CXOSHeader) { | ||
| if (hideMatNameColumn) { | ||
| const orderMatNameHeader = CXOSHeader.querySelector("th:nth-of-type(4)") as HTMLElement; | ||
| orderMatNameHeader.style.display = "None"; | ||
| } | ||
| if (addOrderValueColumn) { | ||
| const orderStatusHeader = CXOSHeader.querySelector("th:nth-of-type(7)"); | ||
| const newHeader = document.createElement("th"); | ||
| newHeader.classList.add(tag); | ||
| newHeader.textContent = "Value"; | ||
| CXOSHeader.insertBefore(newHeader, orderStatusHeader); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function workCXOSRows(tag) { | ||
| const orderRows = document.querySelectorAll(Selector.CXOrdersTable + " > tbody > tr"); | ||
| Array.from(orderRows).forEach((row) => { | ||
| //console.warn(row); | ||
| if (hideMatNameColumn) { | ||
| const matNameCell = row.querySelector("td:nth-of-type(4)") as HTMLElement; | ||
| matNameCell.style.display = "None"; | ||
| } | ||
| if (addOrderValueColumn) { | ||
| const orderStatusCell = row.querySelector("td:nth-of-type(7)"); | ||
| if (orderStatusCell!.childElementCount) { | ||
| const amount = parseInt(row.querySelector("td:nth-of-type(5)")!.childNodes[0].textContent!.replace(/[,.]/g, '')); | ||
| const unitPrice = parseInt(row.querySelector("td:nth-of-type(6)")!.childNodes[0].textContent!.replace(/[,.]/g, '')) / 100; | ||
| const type = row.querySelector("td:nth-of-type(2)")!.textContent; | ||
| const newCell = document.createElement("td"); | ||
| newCell.classList.add(tag); | ||
| newCell.textContent = toFixed(amount * unitPrice, 2); | ||
| newCell.style.textAlign = "right"; | ||
| if (type == "BUY") { | ||
| newCell.style.color = "#50c878"; | ||
| } | ||
| if (type == "SELL") { | ||
| newCell.style.color = "#d0312d"; | ||
| } | ||
| row.insertBefore(newCell, orderStatusCell); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belongs in your global gitignore file