Skip to content

Commit 5c0b405

Browse files
committed
feat(coretax): add download all for my document page
1 parent fd6704d commit 5c0b405

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/coretax/main.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { waitElement } from "@/lib/dom.ts";
2+
import { TIMEOUT } from "@/coretax/ui/constant.ts";
3+
import { Main } from "@/coretax/ui/layout.ts";
4+
import { TableData } from "@/coretax/ui/table.ts";
5+
6+
async function patch_for_my_document() {
7+
const main = await Main();
8+
9+
const table_element = await waitElement<HTMLTableElement>(
10+
"table",
11+
main,
12+
TIMEOUT,
13+
);
14+
const table = new TableData(table_element);
15+
const header_nth = table.headers_text().findIndex((e) => e == "Aksi");
16+
const header_action = table
17+
.headers_action_element()[header_nth];
18+
19+
const download_all_button_click_handler = () => {
20+
const buttons = table.cells_element().map((row) =>
21+
row[header_nth].querySelector("button")
22+
).filter((button) => button != null);
23+
buttons.forEach((button) => button.click());
24+
};
25+
const download_all_button = document.createElement("button");
26+
download_all_button.id = "ActionDownloadButton";
27+
download_all_button.className =
28+
"ct-ovw-btn-mini-save mr-2 mt-1 ng-star-inserted";
29+
download_all_button.innerText = "Unduh";
30+
download_all_button.addEventListener(
31+
"click",
32+
download_all_button_click_handler,
33+
);
34+
35+
header_action.appendChild(download_all_button);
36+
}
37+
38+
await (async () => {
39+
if (
40+
window.location.href ==
41+
"https://coretaxdjp.pajak.go.id/registration-portal/id-ID/documents"
42+
) {
43+
await patch_for_my_document();
44+
}
45+
})();

0 commit comments

Comments
 (0)