summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/icons/back.svg4
-rw-r--r--client/icons/canvas.svg1
-rw-r--r--client/icons/chat.svg4
-rw-r--r--client/icons/dismiss.svg4
-rw-r--r--client/icons/forward.svg4
-rw-r--r--client/icons/home.svg4
-rw-r--r--client/icons/new.svg5
-rw-r--r--client/icons/placeholder.svg4
-rw-r--r--client/icons/reload.svg5
-rw-r--r--client/icons/shield-off.svg3
-rw-r--r--client/icons/shield-on.svg3
-rw-r--r--client/icons/stop.svg4
-rw-r--r--client/index.html65
-rwxr-xr-xclient/main.js157
14 files changed, 240 insertions, 27 deletions
diff --git a/client/icons/back.svg b/client/icons/back.svg
index 22c19e6..587d4fe 100644
--- a/client/icons/back.svg
+++ b/client/icons/back.svg
@@ -1 +1,3 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.295 19.716a1 1 0 0 0 1.404-1.425l-5.37-5.29h13.67a1 1 0 1 0 0-2H6.336L11.7 5.714a1 1 0 0 0-1.404-1.424l-6.924 6.822a1.25 1.25 0 0 0 0 1.78l6.924 6.823Z" fill="#000000"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
+ <path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/canvas.svg b/client/icons/canvas.svg
deleted file mode 100644
index 5247dd2..0000000
--- a/client/icons/canvas.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3.839 5.858c2.94-3.916 9.03-5.055 13.364-2.36 4.28 2.66 5.854 7.777 4.1 12.577-1.655 4.533-6.016 6.328-9.159 4.048-1.177-.854-1.634-1.925-1.854-3.664l-.106-.987-.045-.398c-.123-.934-.311-1.352-.705-1.572-.535-.298-.892-.305-1.595-.033l-.351.146-.179.078c-1.014.44-1.688.595-2.541.416l-.2-.047-.164-.047c-2.789-.864-3.202-4.647-.565-8.157Zm12.928 4.722a1.25 1.25 0 1 0 2.415-.647 1.25 1.25 0 0 0-2.415.647Zm.495 3.488a1.25 1.25 0 1 0 2.414-.647 1.25 1.25 0 0 0-2.414.647Zm-2.474-6.491a1.25 1.25 0 1 0 2.415-.647 1.25 1.25 0 0 0-2.415.647Zm-.028 8.998a1.25 1.25 0 1 0 2.415-.647 1.25 1.25 0 0 0-2.415.647Zm-3.497-9.97a1.25 1.25 0 1 0 2.415-.646 1.25 1.25 0 0 0-2.415.646Z" fill="#212121"/></svg> \ No newline at end of file
diff --git a/client/icons/chat.svg b/client/icons/chat.svg
index 1b2deb2..487d142 100644
--- a/client/icons/chat.svg
+++ b/client/icons/chat.svg
@@ -1 +1,3 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M9.5 3a7.5 7.5 0 0 0-6.797 10.675 68.094 68.094 0 0 0-.681 3.142.996.996 0 0 0 1.153 1.17c.623-.11 1.978-.36 3.236-.65A7.5 7.5 0 1 0 9.5 3Zm-.038 16a7.473 7.473 0 0 0 5.1 2c1.1 0 2.145-.237 3.088-.663 1.043.244 2.186.488 2.913.64a1.244 1.244 0 0 0 1.467-1.5c-.162-.703-.418-1.795-.671-2.803A7.503 7.503 0 0 0 17.015 6.41a8.44 8.44 0 0 1 .8 2.048 5.995 5.995 0 0 1 2.747 5.042c0 .992-.24 1.925-.665 2.747l-.13.253.07.276c.228.895.467 1.9.642 2.65-.774-.163-1.818-.39-2.74-.61l-.264-.062-.243.121c-.804.4-1.71.625-2.67.625a5.974 5.974 0 0 1-2.92-.756 8.517 8.517 0 0 1-2.18.256Z" fill="#212121"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat" viewBox="0 0 16 16">
+ <path d="M2.678 11.894a1 1 0 0 1 .287.801 11 11 0 0 1-.398 2c1.395-.323 2.247-.697 2.634-.893a1 1 0 0 1 .71-.074A8 8 0 0 0 8 14c3.996 0 7-2.807 7-6s-3.004-6-7-6-7 2.808-7 6c0 1.468.617 2.83 1.678 3.894m-.493 3.905a22 22 0 0 1-.713.129c-.2.032-.352-.176-.273-.362a10 10 0 0 0 .244-.637l.003-.01c.248-.72.45-1.548.524-2.319C.743 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7-3.582 7-8 7a9 9 0 0 1-2.347-.306c-.52.263-1.639.742-3.468 1.105"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/dismiss.svg b/client/icons/dismiss.svg
index c4b81e1..b689cbb 100644
--- a/client/icons/dismiss.svg
+++ b/client/icons/dismiss.svg
@@ -1 +1,3 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m4.21 4.387.083-.094a1 1 0 0 1 1.32-.083l.094.083L12 10.585l6.293-6.292a1 1 0 1 1 1.414 1.414L13.415 12l6.292 6.293a1 1 0 0 1 .083 1.32l-.083.094a1 1 0 0 1-1.32.083l-.094-.083L12 13.415l-6.293 6.292a1 1 0 0 1-1.414-1.414L10.585 12 4.293 5.707a1 1 0 0 1-.083-1.32l.083-.094-.083.094Z" fill="#000000"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
+ <path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/forward.svg b/client/icons/forward.svg
index 65b7014..2362904 100644
--- a/client/icons/forward.svg
+++ b/client/icons/forward.svg
@@ -1 +1,3 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.704 4.284a1 1 0 1 0-1.403 1.424L17.67 11H4a1 1 0 1 0 0 2h13.665L12.3 18.285a1 1 0 0 0 1.403 1.424l6.925-6.822a1.25 1.25 0 0 0 0-1.78l-6.925-6.823Z" fill="#000000"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16">
+ <path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/home.svg b/client/icons/home.svg
index b86dbc7..daa093b 100644
--- a/client/icons/home.svg
+++ b/client/icons/home.svg
@@ -1 +1,3 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.55 2.533a2.25 2.25 0 0 1 2.9 0l6.75 5.695c.508.427.8 1.056.8 1.72v9.802a1.75 1.75 0 0 1-1.75 1.75h-3a1.75 1.75 0 0 1-1.75-1.75v-5a.75.75 0 0 0-.75-.75h-3.5a.75.75 0 0 0-.75.75v5a1.75 1.75 0 0 1-1.75 1.75h-3A1.75 1.75 0 0 1 3 19.75V9.947c0-.663.292-1.292.8-1.72l6.75-5.694Z" fill="#212121"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house-door" viewBox="0 0 16 16">
+ <path d="M8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4.5a.5.5 0 0 0 .5-.5v-4h2v4a.5.5 0 0 0 .5.5H14a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM2.5 14V7.707l5.5-5.5 5.5 5.5V14H10v-4a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v4z"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/new.svg b/client/icons/new.svg
index 3733980..2832373 100644
--- a/client/icons/new.svg
+++ b/client/icons/new.svg
@@ -1 +1,4 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2Zm0 5a.75.75 0 0 0-.743.648l-.007.102v3.5h-3.5a.75.75 0 0 0-.102 1.493l.102.007h3.5v3.5a.75.75 0 0 0 1.493.102l.007-.102v-3.5h3.5a.75.75 0 0 0 .102-1.493l-.102-.007h-3.5v-3.5A.75.75 0 0 0 12 7Z" fill="#212121"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16">
+ <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
+ <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/placeholder.svg b/client/icons/placeholder.svg
index 453323c..835ff66 100644
--- a/client/icons/placeholder.svg
+++ b/client/icons/placeholder.svg
@@ -1 +1,3 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 3A3.5 3.5 0 0 0 3 6.5v11A3.5 3.5 0 0 0 6.5 21h11a3.5 3.5 0 0 0 3.5-3.5v-11A3.5 3.5 0 0 0 17.5 3h-11ZM5 8h14v9.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 17.5V8Z" fill="#212121"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-globe" viewBox="0 0 16 16">
+ <path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8m7.5-6.923c-.67.204-1.335.82-1.887 1.855A8 8 0 0 0 5.145 4H7.5zM4.09 4a9.3 9.3 0 0 1 .64-1.539 7 7 0 0 1 .597-.933A7.03 7.03 0 0 0 2.255 4zm-.582 3.5c.03-.877.138-1.718.312-2.5H1.674a7 7 0 0 0-.656 2.5zM4.847 5a12.5 12.5 0 0 0-.338 2.5H7.5V5zM8.5 5v2.5h2.99a12.5 12.5 0 0 0-.337-2.5zM4.51 8.5a12.5 12.5 0 0 0 .337 2.5H7.5V8.5zm3.99 0V11h2.653c.187-.765.306-1.608.338-2.5zM5.145 12q.208.58.468 1.068c.552 1.035 1.218 1.65 1.887 1.855V12zm.182 2.472a7 7 0 0 1-.597-.933A9.3 9.3 0 0 1 4.09 12H2.255a7 7 0 0 0 3.072 2.472M3.82 11a13.7 13.7 0 0 1-.312-2.5h-2.49c.062.89.291 1.733.656 2.5zm6.853 3.472A7 7 0 0 0 13.745 12H11.91a9.3 9.3 0 0 1-.64 1.539 7 7 0 0 1-.597.933M8.5 12v2.923c.67-.204 1.335-.82 1.887-1.855q.26-.487.468-1.068zm3.68-1h2.146c.365-.767.594-1.61.656-2.5h-2.49a13.7 13.7 0 0 1-.312 2.5m2.802-3.5a7 7 0 0 0-.656-2.5H12.18c.174.782.282 1.623.312 2.5zM11.27 2.461c.247.464.462.98.64 1.539h1.835a7 7 0 0 0-3.072-2.472c.218.284.418.598.597.933M10.855 4a8 8 0 0 0-.468-1.068C9.835 1.897 9.17 1.282 8.5 1.077V4z"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/reload.svg b/client/icons/reload.svg
index 5247905..324d5af 100644
--- a/client/icons/reload.svg
+++ b/client/icons/reload.svg
@@ -1 +1,4 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 4.75a7.25 7.25 0 1 0 7.201 6.406c-.068-.588.358-1.156.95-1.156.515 0 .968.358 1.03.87a9.25 9.25 0 1 1-3.432-6.116V4.25a1 1 0 1 1 2.001 0v2.698l.034.052h-.034v.25a1 1 0 0 1-1 1h-3a1 1 0 1 1 0-2h.666A7.219 7.219 0 0 0 12 4.75Z" fill="#000000"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
+ <path fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2z"/>
+ <path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/shield-off.svg b/client/icons/shield-off.svg
new file mode 100644
index 0000000..abc01b1
--- /dev/null
+++ b/client/icons/shield-off.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shield-slash" viewBox="0 0 16 16">
+ <path fill-rule="evenodd" d="M1.093 3.093c-.465 4.275.885 7.46 2.513 9.589a11.8 11.8 0 0 0 2.517 2.453c.386.273.744.482 1.048.625.28.132.581.24.829.24s.548-.108.829-.24a7 7 0 0 0 1.048-.625 11.3 11.3 0 0 0 1.733-1.525l-.745-.745a10.3 10.3 0 0 1-1.578 1.392c-.346.244-.652.42-.893.533q-.18.085-.293.118a1 1 0 0 1-.101.025 1 1 0 0 1-.1-.025 2 2 0 0 1-.294-.118 6 6 0 0 1-.893-.533 10.7 10.7 0 0 1-2.287-2.233C3.053 10.228 1.879 7.594 2.06 4.06zM3.98 1.98l-.852-.852A59 59 0 0 1 5.072.559C6.157.266 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.483 3.626-.332 6.491-1.551 8.616l-.77-.77c1.042-1.915 1.72-4.469 1.29-7.702a.48.48 0 0 0-.33-.39c-.65-.213-1.75-.56-2.836-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524a50 50 0 0 0-1.357.39zm9.666 12.374-13-13 .708-.708 13 13z"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/shield-on.svg b/client/icons/shield-on.svg
new file mode 100644
index 0000000..7e18d1b
--- /dev/null
+++ b/client/icons/shield-on.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shield" viewBox="0 0 16 16">
+ <path d="M5.338 1.59a61 61 0 0 0-2.837.856.48.48 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.7 10.7 0 0 0 2.287 2.233c.346.244.652.42.893.533q.18.085.293.118a1 1 0 0 0 .101.025 1 1 0 0 0 .1-.025q.114-.034.294-.118c.24-.113.547-.29.893-.533a10.7 10.7 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.8 11.8 0 0 1-2.517 2.453 7 7 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7 7 0 0 1-1.048-.625 11.8 11.8 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 63 63 0 0 1 5.072.56"/>
+</svg> \ No newline at end of file
diff --git a/client/icons/stop.svg b/client/icons/stop.svg
index c4b81e1..b689cbb 100644
--- a/client/icons/stop.svg
+++ b/client/icons/stop.svg
@@ -1 +1,3 @@
-<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m4.21 4.387.083-.094a1 1 0 0 1 1.32-.083l.094.083L12 10.585l6.293-6.292a1 1 0 1 1 1.414 1.414L13.415 12l6.292 6.293a1 1 0 0 1 .083 1.32l-.083.094a1 1 0 0 1-1.32.083l-.094-.083L12 13.415l-6.293 6.292a1 1 0 0 1-1.414-1.414L10.585 12 4.293 5.707a1 1 0 0 1-.083-1.32l.083-.094-.083.094Z" fill="#000000"/></svg> \ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
+ <path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/>
+</svg> \ No newline at end of file
diff --git a/client/index.html b/client/index.html
index 1ebd8e8..a0661a9 100644
--- a/client/index.html
+++ b/client/index.html
@@ -56,9 +56,25 @@
.nav-item:not(.active):hover .nav-link {
border-color: transparent !important;
}
+
+ @media (prefers-color-scheme: dark) {
+ #tabs, .bar {
+ background-color: #ddd;
+ filter: invert(1) hue-rotate(180deg);
+ }
+
+ .nav-link.active {
+ background-color: #ddd !important;
+ border-bottom: none !important;
+ }
+
+ img:not([src$=".svg"]) {
+ filter: invert(1) hue-rotate(180deg);
+ }
+ }
</style>
</head>
-<body>
+<body style="overflow-y: hidden;">
<ul id="tabs" class="nav nav-tabs" style="background-color: #eee; -webkit-app-region: drag;"></ul>
<script>
if (process.platform === "darwin") {
@@ -70,10 +86,29 @@
<div id="windows" style="display: flex;"></div>
<script>
+ const ipcRenderer = require('electron').ipcRenderer;
+
window.tabs = [];
window.activeTab = -1;
+ window.protectionEnabled = localStorage.getItem("protection-status") !== "false";
+
+ function toggleProtection() {
+ window.protectionEnabled = !window.protectionEnabled;
+ localStorage.setItem("protection-status", JSON.stringify(window.protectionEnabled));
+ refreshInternalProtection();
+ refreshTabBar();
+ }
+
+ function refreshInternalProtection() {
+ if (window.protectionEnabled) {
+ ipcRenderer.send("enable-protection");
+ } else {
+ ipcRenderer.send("disable-protection");
+ }
+ }
function refreshTabBar() {
+ console.log(window.activeTab);
let id = window.activeTab;
if (id > -1) {
@@ -84,13 +119,15 @@
tabs[id].webview.classList.add("open");
}
- document.getElementById("tabs").innerHTML = window.tabs.map((i, j) => `
- <li class="nav-item ${i.chat ? 'pinned' : ''}">
- <a class="nav-link ${j === window.activeTab ? 'active' : ''}" aria-current="page" href="#"><img onclick="switchToTab(${j});" style="width: 24px; height: 24px;" alt="" src="${i.icon}"><span class="tab-text" onclick="switchToTab(${j});" style="vertical-align: middle; margin-left: 5px; width: 171px; display: inline-block; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis">${i.name}</span><span class="tab-close" style="display: inline-block;" onclick="event.preventDefault(); closeTab(${j});"><img alt="" src="./icons/dismiss.svg"></span></a>
+ document.getElementById("tabs").innerHTML = `<div style="display: grid; grid-template-columns: 1fr max-content; width: 100%;"><span>` + window.tabs.map((i, j) => `
+ <li class="nav-item ${i.chat ? 'pinned' : ''}" style="width: max-content; display: inline-block;">
+ <a class="nav-link ${j === window.activeTab ? 'active' : ''}" aria-current="page" href="#" onclick="if (event.target.classList.contains('nav-link')) switchToTab(${j});"><img style="width: 24px; height: 24px; pointer-events: none;" alt="" src="${i.icon}"><span class="tab-text" onclick="switchToTab(${j});" style="vertical-align: middle; margin-left: 5px; width: 171px; display: inline-block; white-space: nowrap; overflow: hidden !important; text-overflow: ellipsis">${i.name}</span><span class="tab-close" style="display: inline-block;" onclick="event.preventDefault(); closeTab(${j});"><img alt="" src="./icons/dismiss.svg"></span></a>
</li>
- `).join("") + `<li class="nav-item">
+ `).join("") + `<li class="nav-item" style="width: max-content; display: inline-block;">
<a class="nav-link" aria-current="page" href="#" onclick="openHome();"><img alt="" src="./icons/new.svg"></a>
- </li>`;
+ </li></span><span><li class="nav-item" style="width: max-content; display: inline-block;">
+ <a class="nav-link" aria-current="page" href="#" onclick="toggleProtection();"><img id="ad-protection-img" alt="" src="./icons/${window.protectionEnabled ? 'shield-on' : 'shield-off'}.svg"></a>
+ </li></span></div>`;
if (tabs[window.activeTab]) document.title = tabs[window.activeTab].name + " ยท Chatroom Workspace";
}
@@ -165,8 +202,6 @@
webview.addEventListener('page-title-updated', (e) => {
if (webview.getURL().startsWith("https://school.equestria.dev/")) {
tab.name = "Chat";
- } else if (webview.getURL().startsWith("https://canvas.apps.chrome/")) {
- tab.name = "Canvas";
} else {
tab.name = e.title;
}
@@ -176,8 +211,6 @@
webview.addEventListener('page-favicon-updated', (e) => {
if (webview.getURL().startsWith("https://school.equestria.dev/")) {
tab.icon = "./icons/chat.svg";
- } else if (webview.getURL().startsWith("https://canvas.apps.chrome/")) {
- tab.icon = "./icons/canvas.svg";
} else {
tab.icon = e.favicons[0] ?? "./icons/placeholder.svg";
}
@@ -218,6 +251,7 @@
}
function switchToTab(id) {
+ console.log("<", id);
window.activeTab = id;
refreshTabBar();
}
@@ -253,24 +287,27 @@
document.getElementById("wv-item-" + tabs[id].id).outerHTML = "";
window.tabs = tabs.filter((i, j) => j !== id);
+ console.log("C3");
refreshTabBar();
}
function closeCurrentTab() {
let oldActiveTab = window.activeTab;
+ let newActiveTab = window.activeTab;
if (tabs.length === 1) {
window.close();
return;
- } else if (window.activeTab === tabs.length - 1) {
- window.activeTab--;
+ } else if (newActiveTab === tabs.length - 1) {
+ newActiveTab--;
}
document.getElementById("wv-item-" + tabs[oldActiveTab].id).outerHTML = "";
window.tabs = tabs.filter((i, j) => j !== oldActiveTab);
- console.log(window.activeTab);
- switchToTab(window.activeTab);
+ console.log(">", newActiveTab, oldActiveTab);
+ console.log("C2");
+ switchToTab(newActiveTab);
}
function switchRight() {
diff --git a/client/main.js b/client/main.js
index a913e42..bc73211 100755
--- a/client/main.js
+++ b/client/main.js
@@ -1,17 +1,168 @@
const { app, BrowserWindow, webContents, globalShortcut, ipcMain, session, dialog, MenuItem, Menu, desktopCapturer, clipboard, nativeImage } = require('electron');
const path = require('path');
const os = require("os");
-const {writeFileSync, existsSync, unlinkSync} = require("fs");
+const {appendFileSync, writeFileSync, existsSync, unlinkSync} = require("fs");
const fs = require("fs");
+try {
+ if (!app.getAppPath().endsWith("/launcher/client")) writeFileSync(app.getAppPath() + "/index.html", `
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>Chatroom</title>
+ <style>
+ #loader-circle-1, #loader-circle-2, #loader-circle-3 {
+ animation-name: opacity;
+ animation-timing-function: linear;
+ animation-duration: 1.2s;
+ animation-fill-mode: forwards;
+ animation-iteration-count: infinite;
+ }
+
+ #loader-circle-2 {
+ animation-delay: .25s;
+ }
+
+ #loader-circle-3 {
+ animation-delay: .5s;
+ }
+
+ @keyframes opacity {
+ 0% {
+ opacity: 0;
+ }
+ 50% {
+ opacity: 1;
+ }
+ 100% {
+ opacity: 0;
+ }
+ }
+ </style>
+ <script>
+ const { ipcRenderer } = require('electron');
+
+ ipcRenderer.on('local', (_, data) => {
+ loadApp(data);
+ });
+
+ ipcRenderer.on('download', (_) => {
+ download();
+ });
+
+ function download() {
+ document.getElementById("status").innerText = "Downloading application... 0%";
+
+ const axios = require('./node_modules/axios/dist/node/axios.cjs');
+ const fs = require("fs");
+ const zlib = require("zlib");
+ const crypto = require("crypto");
+
+ let tempDir = require('@electron/remote').app.getPath('userData') + "/Chatroom";
+ if (fs.existsSync(tempDir)) fs.rmSync(tempDir, { recursive: true });
+ fs.mkdirSync(tempDir);
+
+ function downloadClient() {
+ return new Promise(async (res) => {
+ const response = await axios({
+ url: "http://51.68.173.117:21938/update/client.lctpk?_" + require('crypto').randomBytes(64).toString("hex"),
+ method: 'GET',
+ responseType: 'blob',
+ onDownloadProgress: (event) => {
+ document.getElementById("status").innerText = "Downloading application... " + Math.round(((event.loaded / event.total) / 2) * 100) + "%";
+ }
+ });
+
+ document.getElementById("status").innerText = "Extracting...";
+
+ res(JSON.parse(zlib.brotliDecompressSync(Buffer.from(await response.data.arrayBuffer())).toString()).map(i => {
+ if (i['content']) i['content'] = zlib.brotliDecompressSync(Buffer.from(i['content'], "base64"));
+ if (i['hash']) i['hash'] = crypto.createHash("sha256").update(i['content']).digest("base64") === i['hash'];
+ return i;
+ }));
+ });
+ }
+
+ (async () => {
+ let _client = await downloadClient();
+ let files = [..._client];
+
+ document.getElementById("status").innerText = "Installing application... 0%";
+ let total = files.length;
+ let index = 0;
+
+ for (let file of files) {
+ if (file.type === "file" && !file.hash) {
+ alert("Unable to continue: file " + file.name + " is corrupted");
+ window.close();
+ }
+
+ if (file.type === "file") {
+ fs.writeFileSync(tempDir + "/" + file.name, file.content);
+ } else {
+ if (!fs.existsSync(tempDir + "/" + file.name)) fs.mkdirSync(tempDir + "/" + file.name);
+ }
+
+ index++;
+ document.getElementById("status").innerText = "Installing application... " + Math.round((index / total) * 100) + "%";
+ }
+
+ document.getElementById("status").innerText = "Starting...";
+
+ loadApp(tempDir + "/client");
+ })();
+ }
+
+ function loadApp(path) {
+ ipcRenderer.send("start", path);
+ }
+
+ alert("Automatic updates could work on this system! Please click on OK and tell Raindrops.");
+ </script>
+</head>
+<body style="margin: 0; user-select: none;">
+ <div style="position: fixed; inset: 0; z-index: 9999; -webkit-app-region: drag;"></div>
+
+ <div style="position: fixed; inset: 0; z-index: 999; display: flex; align-items: center; justify-content: center; text-align: center;">
+ <div>
+ <svg style="opacity: .25;" id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 203.96 171.05">
+ <defs>
+ <style>
+ .cls-1 {
+ fill: #fff;
+ }
+ </style>
+ </defs>
+ <path class="cls-1" d="M40.49,144.2c-3.75-2.02-6.68-4.84-8.77-8.44-2.09-3.61-3.14-7.51-3.14-11.69v-45.47l-22.73-12.55c-2.04-1.14-3.53-2.56-4.45-4.27-.93-1.71-1.39-3.6-1.39-5.69s.46-3.92,1.39-5.71c.93-1.79,2.41-3.27,4.45-4.47L84.66,2.81c1.73-1.01,3.52-1.73,5.36-2.17s3.74-.65,5.68-.65,3.83,.22,5.68,.65,3.63,1.15,5.36,2.17l91.37,49.8c1.86,.95,3.29,2.32,4.32,4.13,1.02,1.8,1.53,3.75,1.53,5.83v61.06c0,3.18-1.12,5.88-3.36,8.12s-4.94,3.36-8.12,3.36-5.88-1.12-8.12-3.36c-2.24-2.24-3.36-4.94-3.36-8.12v-55.21l-18.19,10.18v45.47c0,4.19-1.05,8.08-3.14,11.69-2.09,3.61-5.02,6.42-8.77,8.44l-44.17,24.03c-1.73,1.01-3.52,1.73-5.36,2.17-1.84,.43-3.74,.65-5.68,.65s-3.83-.22-5.68-.65c-1.84-.43-3.63-1.15-5.36-2.17l-44.17-24.03Zm55.21-55.43l60.63-32.91L95.7,23.17,35.29,55.86l60.41,32.91Zm0,59.11l44.17-23.82v-33.56l-33.13,18.4c-1.73,1.01-3.5,1.73-5.3,2.17-1.8,.43-3.72,.65-5.74,.65s-3.93-.22-5.74-.65-3.57-1.15-5.3-2.17l-33.13-18.4v33.56l44.17,23.82Z"/>
+ </svg>
+ <br>
+ <p style="color: white; opacity: .25; font-family: system-ui, -apple-system, sans-serif;" id="status">Starting...</p>
+ </div>
+ </div>
+</body>
+</html>
+`);
+} catch (e) {
+ console.error(e);
+}
+
const { ElectronBlocker } = require('@cliqz/adblocker-electron');
const { fetch } = require('cross-fetch');
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
- blocker.enableBlockingInSession(session.defaultSession);
+ global.blocker = blocker;
+});
+
+ipcMain.on('enable-protection', () => {
+ global.blocker.enableBlockingInSession(session.defaultSession);
+});
+
+ipcMain.on('disable-protection', () => {
+ global.blocker.disableBlockingInSession(session.defaultSession);
});
-session.defaultSession.setUserAgent(session.defaultSession.getUserAgent().replace(/(.*)( Electron\/(.*) )/gm, "$1 ") + " Chatroom/1.0.0")
+session.defaultSession.setUserAgent(session.defaultSession.getUserAgent().replace(/(.*)( Electron\/(.*) )/gm, "$1 ") + " Chatroom/1.0.0");
let localchatDataRoot = (os.platform() === "win32" ? os.homedir() + "/AppData/Roaming" : (os.platform() === "darwin" ? os.homedir() + "/Library/Application Support" : os.homedir())) + (os.platform() === "darwin" ? "/ChatroomWorkspace" : "/.chatroom-workspace");