diff --git a/README.md b/README.md index 8b60529..ed0874d 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ Standalone desktop app that monitors your PTW sessions page and automatically di - PTW_CAPTOR - PTW_IEC_FAULT - PTW_IEC61363 +- 19 +- 9 ## Requirements diff --git a/dist/PTW Auto-Disconnect 2.1.0.exe b/dist/PTW Auto-Disconnect 2.1.0.exe index 2a16342..69c98ed 100644 --- a/dist/PTW Auto-Disconnect 2.1.0.exe +++ b/dist/PTW Auto-Disconnect 2.1.0.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ff2524a9d1e7f032fa2421273e8940380a73bfd4724cd402d5488be79da09d81 -size 75943514 +oid sha256:056773870bc38cf00f4b67b06281b627355be2cc86611d208a068df33a868866 +size 75946704 diff --git a/dist/PTW Auto-Disconnect Setup 2.1.0.exe b/dist/PTW Auto-Disconnect Setup 2.1.0.exe index 2dab5a9..3c427f0 100644 --- a/dist/PTW Auto-Disconnect Setup 2.1.0.exe +++ b/dist/PTW Auto-Disconnect Setup 2.1.0.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:388a3e0f3f5f9e32a8297383bd1c9fc85aa5ecb344b7f8a26edad3a019831a47 -size 76109252 +oid sha256:30c8f2cbf3dbed46b2f1b9ed1db15cad0b63d435dbc341fd125dce92f17e1e92 +size 76112438 diff --git a/dist/PTW Auto-Disconnect Setup 2.1.0.exe.blockmap b/dist/PTW Auto-Disconnect Setup 2.1.0.exe.blockmap index c2213a3..d7e0812 100644 Binary files a/dist/PTW Auto-Disconnect Setup 2.1.0.exe.blockmap and b/dist/PTW Auto-Disconnect Setup 2.1.0.exe.blockmap differ diff --git a/dist/builder-debug.yml b/dist/builder-debug.yml index 8a521f1..2798917 100644 --- a/dist/builder-debug.yml +++ b/dist/builder-debug.yml @@ -13,4 +13,4 @@ x64: - '!.yarnrc.yml' nodeModuleFilePatterns: [] nsis: - script: "!include \"C:\\Users\\Michael Sloan\\Desktop\\git\\SKM login kicker\\node_modules\\app-builder-lib\\templates\\nsis\\include\\StdUtils.nsh\"\n!addincludedir \"C:\\Users\\Michael Sloan\\Desktop\\git\\SKM login kicker\\node_modules\\app-builder-lib\\templates\\nsis\\include\"\n!macro _isUpdated _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"updated\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isUpdated `\"\" isUpdated \"\"`\n\n!macro _isForceRun _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"force-run\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isForceRun `\"\" isForceRun \"\"`\n\n!macro _isKeepShortcuts _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"keep-shortcuts\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isKeepShortcuts `\"\" isKeepShortcuts \"\"`\n\n!macro _isNoDesktopShortcut _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"no-desktop-shortcut\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isNoDesktopShortcut `\"\" isNoDesktopShortcut \"\"`\n\n!macro _isDeleteAppData _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"delete-app-data\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isDeleteAppData `\"\" isDeleteAppData \"\"`\n\n!macro _isForAllUsers _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"allusers\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isForAllUsers `\"\" isForAllUsers \"\"`\n\n!macro _isForCurrentUser _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"currentuser\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isForCurrentUser `\"\" isForCurrentUser \"\"`\n\n!macro addLangs\n !insertmacro MUI_LANGUAGE \"English\"\n !insertmacro MUI_LANGUAGE \"German\"\n !insertmacro MUI_LANGUAGE \"French\"\n !insertmacro MUI_LANGUAGE \"SpanishInternational\"\n !insertmacro MUI_LANGUAGE \"SimpChinese\"\n !insertmacro MUI_LANGUAGE \"TradChinese\"\n !insertmacro MUI_LANGUAGE \"Japanese\"\n !insertmacro MUI_LANGUAGE \"Korean\"\n !insertmacro MUI_LANGUAGE \"Italian\"\n !insertmacro MUI_LANGUAGE \"Dutch\"\n !insertmacro MUI_LANGUAGE \"Danish\"\n !insertmacro MUI_LANGUAGE \"Swedish\"\n !insertmacro MUI_LANGUAGE \"Norwegian\"\n !insertmacro MUI_LANGUAGE \"Finnish\"\n !insertmacro MUI_LANGUAGE \"Russian\"\n !insertmacro MUI_LANGUAGE \"Portuguese\"\n !insertmacro MUI_LANGUAGE \"PortugueseBR\"\n !insertmacro MUI_LANGUAGE \"Polish\"\n !insertmacro MUI_LANGUAGE \"Ukrainian\"\n !insertmacro MUI_LANGUAGE \"Czech\"\n !insertmacro MUI_LANGUAGE \"Slovak\"\n !insertmacro MUI_LANGUAGE \"Hungarian\"\n !insertmacro MUI_LANGUAGE \"Arabic\"\n !insertmacro MUI_LANGUAGE \"Turkish\"\n !insertmacro MUI_LANGUAGE \"Thai\"\n !insertmacro MUI_LANGUAGE \"Vietnamese\"\n!macroend\n\n!addplugindir /x86-unicode \"C:\\Users\\Michael Sloan\\AppData\\Local\\electron-builder\\Cache\\nsis\\nsis-resources-3.4.1\\plugins\\x86-unicode\"\n!include \"C:\\Users\\MICHAE~1\\AppData\\Local\\Temp\\t-HVKMHS\\1-messages.nsh\"\n\n!include \"common.nsh\"\n!include \"extractAppPackage.nsh\"\n\n# https://github.com/electron-userland/electron-builder/issues/3972#issuecomment-505171582\nCRCCheck off\nWindowIcon Off\nAutoCloseWindow True\nRequestExecutionLevel ${REQUEST_EXECUTION_LEVEL}\n\nFunction .onInit\n !ifndef SPLASH_IMAGE\n SetSilent silent\n !endif\n\n !insertmacro check64BitAndSetRegView\nFunctionEnd\n\nFunction .onGUIInit\n InitPluginsDir\n\n !ifdef SPLASH_IMAGE\n File /oname=$PLUGINSDIR\\splash.bmp \"${SPLASH_IMAGE}\"\n BgImage::SetBg $PLUGINSDIR\\splash.bmp\n BgImage::Redraw\n !endif\nFunctionEnd\n\nSection\n !ifdef SPLASH_IMAGE\n HideWindow\n !endif\n\n StrCpy $INSTDIR \"$PLUGINSDIR\\app\"\n !ifdef UNPACK_DIR_NAME\n StrCpy $INSTDIR \"$TEMP\\${UNPACK_DIR_NAME}\"\n !endif\n\n RMDir /r $INSTDIR\n SetOutPath $INSTDIR\n\n !ifdef APP_DIR_64\n !ifdef APP_DIR_ARM64\n !ifdef APP_DIR_32\n ${if} ${IsNativeARM64}\n File /r \"${APP_DIR_ARM64}\\*.*\"\n ${elseif} ${RunningX64}\n File /r \"${APP_DIR_64}\\*.*\"\n ${else}\n File /r \"${APP_DIR_32}\\*.*\"\n ${endIf}\n !else\n ${if} ${IsNativeARM64}\n File /r \"${APP_DIR_ARM64}\\*.*\"\n ${else}\n File /r \"${APP_DIR_64}\\*.*\"\n {endIf}\n !endif\n !else\n !ifdef APP_DIR_32\n ${if} ${RunningX64}\n File /r \"${APP_DIR_64}\\*.*\"\n ${else}\n File /r \"${APP_DIR_32}\\*.*\"\n ${endIf}\n !else\n File /r \"${APP_DIR_64}\\*.*\"\n !endif\n !endif\n !else\n !ifdef APP_DIR_32\n File /r \"${APP_DIR_32}\\*.*\"\n !else\n !insertmacro extractEmbeddedAppPackage\n !endif\n !endif\n\n System::Call 'Kernel32::SetEnvironmentVariable(t, t)i (\"PORTABLE_EXECUTABLE_DIR\", \"$EXEDIR\").r0'\n System::Call 'Kernel32::SetEnvironmentVariable(t, t)i (\"PORTABLE_EXECUTABLE_FILE\", \"$EXEPATH\").r0'\n System::Call 'Kernel32::SetEnvironmentVariable(t, t)i (\"PORTABLE_EXECUTABLE_APP_FILENAME\", \"${APP_FILENAME}\").r0'\n ${StdUtils.GetAllParameters} $R0 0\n\n !ifdef SPLASH_IMAGE\n BgImage::Destroy\n !endif\n\n\tExecWait \"$INSTDIR\\${APP_EXECUTABLE_FILENAME} $R0\" $0\n SetErrorLevel $0\n\n SetOutPath $EXEDIR\n\tRMDir /r $INSTDIR\nSectionEnd\n" + script: "!include \"C:\\Users\\Michael Sloan\\Desktop\\git\\Start-PTW-Auto-Disconnect\\node_modules\\app-builder-lib\\templates\\nsis\\include\\StdUtils.nsh\"\n!addincludedir \"C:\\Users\\Michael Sloan\\Desktop\\git\\Start-PTW-Auto-Disconnect\\node_modules\\app-builder-lib\\templates\\nsis\\include\"\n!macro _isUpdated _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"updated\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isUpdated `\"\" isUpdated \"\"`\n\n!macro _isForceRun _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"force-run\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isForceRun `\"\" isForceRun \"\"`\n\n!macro _isKeepShortcuts _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"keep-shortcuts\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isKeepShortcuts `\"\" isKeepShortcuts \"\"`\n\n!macro _isNoDesktopShortcut _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"no-desktop-shortcut\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isNoDesktopShortcut `\"\" isNoDesktopShortcut \"\"`\n\n!macro _isDeleteAppData _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"delete-app-data\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isDeleteAppData `\"\" isDeleteAppData \"\"`\n\n!macro _isForAllUsers _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"allusers\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isForAllUsers `\"\" isForAllUsers \"\"`\n\n!macro _isForCurrentUser _a _b _t _f\n ${StdUtils.TestParameter} $R9 \"currentuser\"\n StrCmp \"$R9\" \"true\" `${_t}` `${_f}`\n!macroend\n!define isForCurrentUser `\"\" isForCurrentUser \"\"`\n\n!macro addLangs\n !insertmacro MUI_LANGUAGE \"English\"\n !insertmacro MUI_LANGUAGE \"German\"\n !insertmacro MUI_LANGUAGE \"French\"\n !insertmacro MUI_LANGUAGE \"SpanishInternational\"\n !insertmacro MUI_LANGUAGE \"SimpChinese\"\n !insertmacro MUI_LANGUAGE \"TradChinese\"\n !insertmacro MUI_LANGUAGE \"Japanese\"\n !insertmacro MUI_LANGUAGE \"Korean\"\n !insertmacro MUI_LANGUAGE \"Italian\"\n !insertmacro MUI_LANGUAGE \"Dutch\"\n !insertmacro MUI_LANGUAGE \"Danish\"\n !insertmacro MUI_LANGUAGE \"Swedish\"\n !insertmacro MUI_LANGUAGE \"Norwegian\"\n !insertmacro MUI_LANGUAGE \"Finnish\"\n !insertmacro MUI_LANGUAGE \"Russian\"\n !insertmacro MUI_LANGUAGE \"Portuguese\"\n !insertmacro MUI_LANGUAGE \"PortugueseBR\"\n !insertmacro MUI_LANGUAGE \"Polish\"\n !insertmacro MUI_LANGUAGE \"Ukrainian\"\n !insertmacro MUI_LANGUAGE \"Czech\"\n !insertmacro MUI_LANGUAGE \"Slovak\"\n !insertmacro MUI_LANGUAGE \"Hungarian\"\n !insertmacro MUI_LANGUAGE \"Arabic\"\n !insertmacro MUI_LANGUAGE \"Turkish\"\n !insertmacro MUI_LANGUAGE \"Thai\"\n !insertmacro MUI_LANGUAGE \"Vietnamese\"\n!macroend\n\n!addplugindir /x86-unicode \"C:\\Users\\Michael Sloan\\AppData\\Local\\electron-builder\\Cache\\nsis\\nsis-resources-3.4.1\\plugins\\x86-unicode\"\n!include \"C:\\Users\\MICHAE~1\\AppData\\Local\\Temp\\t-nKXXuQ\\1-messages.nsh\"\n\n!include \"common.nsh\"\r\n!include \"extractAppPackage.nsh\"\r\n\r\n# https://github.com/electron-userland/electron-builder/issues/3972#issuecomment-505171582\r\nCRCCheck off\r\nWindowIcon Off\r\nAutoCloseWindow True\r\nRequestExecutionLevel ${REQUEST_EXECUTION_LEVEL}\r\n\r\nFunction .onInit\r\n !ifndef SPLASH_IMAGE\r\n SetSilent silent\r\n !endif\r\n\r\n !insertmacro check64BitAndSetRegView\r\nFunctionEnd\r\n\r\nFunction .onGUIInit\r\n InitPluginsDir\r\n\r\n !ifdef SPLASH_IMAGE\r\n File /oname=$PLUGINSDIR\\splash.bmp \"${SPLASH_IMAGE}\"\r\n BgImage::SetBg $PLUGINSDIR\\splash.bmp\r\n BgImage::Redraw\r\n !endif\r\nFunctionEnd\r\n\r\nSection\r\n !ifdef SPLASH_IMAGE\r\n HideWindow\r\n !endif\r\n\r\n StrCpy $INSTDIR \"$PLUGINSDIR\\app\"\r\n !ifdef UNPACK_DIR_NAME\r\n StrCpy $INSTDIR \"$TEMP\\${UNPACK_DIR_NAME}\"\r\n !endif\r\n\r\n RMDir /r $INSTDIR\r\n SetOutPath $INSTDIR\r\n\r\n !ifdef APP_DIR_64\r\n !ifdef APP_DIR_ARM64\r\n !ifdef APP_DIR_32\r\n ${if} ${IsNativeARM64}\r\n File /r \"${APP_DIR_ARM64}\\*.*\"\r\n ${elseif} ${RunningX64}\r\n File /r \"${APP_DIR_64}\\*.*\"\r\n ${else}\r\n File /r \"${APP_DIR_32}\\*.*\"\r\n ${endIf}\r\n !else\r\n ${if} ${IsNativeARM64}\r\n File /r \"${APP_DIR_ARM64}\\*.*\"\r\n ${else}\r\n File /r \"${APP_DIR_64}\\*.*\"\r\n {endIf}\r\n !endif\r\n !else\r\n !ifdef APP_DIR_32\r\n ${if} ${RunningX64}\r\n File /r \"${APP_DIR_64}\\*.*\"\r\n ${else}\r\n File /r \"${APP_DIR_32}\\*.*\"\r\n ${endIf}\r\n !else\r\n File /r \"${APP_DIR_64}\\*.*\"\r\n !endif\r\n !endif\r\n !else\r\n !ifdef APP_DIR_32\r\n File /r \"${APP_DIR_32}\\*.*\"\r\n !else\r\n !insertmacro extractEmbeddedAppPackage\r\n !endif\r\n !endif\r\n\r\n System::Call 'Kernel32::SetEnvironmentVariable(t, t)i (\"PORTABLE_EXECUTABLE_DIR\", \"$EXEDIR\").r0'\r\n System::Call 'Kernel32::SetEnvironmentVariable(t, t)i (\"PORTABLE_EXECUTABLE_FILE\", \"$EXEPATH\").r0'\r\n System::Call 'Kernel32::SetEnvironmentVariable(t, t)i (\"PORTABLE_EXECUTABLE_APP_FILENAME\", \"${APP_FILENAME}\").r0'\r\n ${StdUtils.GetAllParameters} $R0 0\r\n\r\n !ifdef SPLASH_IMAGE\r\n BgImage::Destroy\r\n !endif\r\n\r\n\tExecWait \"$INSTDIR\\${APP_EXECUTABLE_FILENAME} $R0\" $0\r\n SetErrorLevel $0\r\n\r\n SetOutPath $EXEDIR\r\n\tRMDir /r $INSTDIR\r\nSectionEnd\r\n" diff --git a/dist/win-unpacked/PTW Auto-Disconnect 2.1.0.exe b/dist/win-unpacked/PTW Auto-Disconnect 2.1.0.exe deleted file mode 100644 index 9cf4127..0000000 --- a/dist/win-unpacked/PTW Auto-Disconnect 2.1.0.exe +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ec9a6c995c49fe99eb722a7fba85d2f5ba3c74250505f7083a31c658ee0bfceb -size 75943420 diff --git a/dist/win-unpacked/resources/app/AI_DNA.md b/dist/win-unpacked/resources/app/AI_DNA.md new file mode 100644 index 0000000..0ec30a9 --- /dev/null +++ b/dist/win-unpacked/resources/app/AI_DNA.md @@ -0,0 +1,55 @@ +# AI DNA — Project overview for AI and maintainers + +Short reference so an AI or new dev can understand and modify this project without guessing. + +## What this app is + +- **Electron** desktop app (Windows). One window; no browser opened. +- Connects to **localhost:1947** sessions/config pages in a **hidden webview**. +- **On startup:** Loads config page → ensures “Table Rows per Page” = 100 → submits if changed → loads sessions page. +- **When Monitor ON:** Every 60s reloads sessions page; scans table rows; **clicks Disconnect** on rows whose text contains any of the **target keywords**. +- **UI:** Left = “Logged in” (by user); Right = “Activity log”; bottom = Monitor ON/OFF + Clear. Uses **powerSaveBlocker** so Windows/display don’t sleep while the app runs. + +## Tech stack + +- **Runtime:** Node.js + Electron (main process + one renderer, no Node in renderer). +- **Front-end:** Vanilla JS + one HTML file + inline CSS. No React/Vue/framework. +- **Build:** electron-builder (NSIS installer + portable exe + win-unpacked). `asar: false`. Optional `afterPack.js` for ffmpeg placement. + +## Key files (don’t guess — use these) + +| File | Role | +|------|------| +| **main.js** | Electron main: create window, load index.html, enable webview, powerSaveBlocker. | +| **index.html** | Single UI: webview (hidden), two panels (Logged in left, Activity log right), buttons, status. | +| **renderer.js** | Renderer logic: load config first then sessions, inject scripts, poll for logs/sessions, toggle Monitor, 60s reload. | +| **inject.js** | Injected into the **sessions** page (webview). Defines `__ptw_getSessions()`, `__ptw_flushLogs()`, `__ptw_setRunning()`, and the **TARGET_KEYWORDS** + scan/Disconnect logic. Not used on config page. | +| **preload.js** | Minimal; no Node exposed to renderer. | +| **afterPack.js** | Copies ffmpeg.dll to app root if needed for portable build. | +| **package.json** | Scripts: `start`, `dist`, `dist:portable`. Build: win targets, extraFiles for ffmpeg, afterPack. | + +## Important conventions + +- **Keywords:** Edit **inject.js** only — array `TARGET_KEYWORDS`. Row is disconnected if `row.innerText` contains any keyword. +- **Config check:** In **renderer.js**, `ensureConfigThenSessions()` runs on config.html load; sets `#linesperpage` to 100 and clicks Submit if needed, then navigates webview to sessions. +- **URLs:** Config = `http://localhost:1947/_int_/config.html`, Sessions = `http://localhost:1947/_int_/sessions.html`. Defined in renderer.js. +- **Log/sessions bridge:** Inject script pushes to `__ptw_logQueue` and exposes `__ptw_flushLogs()` / `__ptw_getSessions()`. Renderer polls via `webview.executeJavaScript()` and updates DOM. +- **Persistence:** Monitor ON/OFF and activity log entries in renderer **localStorage** (keys in renderer.js). No backend. + +## Adding a new disconnect keyword + +1. Open **inject.js**. +2. Add the string to the **TARGET_KEYWORDS** array. +3. Save; rebuild if distributing exe (`npm run dist`). + +## Changing config or startup flow + +- Config URL / field / submit: **renderer.js** (`ensureConfigThenSessions` and the injected script string). +- Sessions URL: **renderer.js** (`SESSION_URL`) and **index.html** (webview initial `src` is config; renderer switches to sessions after config check). + +## Build and run + +- **Run:** `npm install` then `npm start` (or **Start PTW Auto-Disconnect.vbs**). +- **Build:** `npm run dist` → installer + portable exe + win-unpacked. Optional: `npm run dist:portable` to also create the zip. + +Keep this file updated when you change architecture, key file roles, or conventions so the “AI DNA” stays accurate. diff --git a/dist/win-unpacked/resources/app/LICENSE b/dist/win-unpacked/resources/app/LICENSE new file mode 100644 index 0000000..b899f84 --- /dev/null +++ b/dist/win-unpacked/resources/app/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 PTW Auto-Disconnect contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dist/win-unpacked/resources/app/README.md b/dist/win-unpacked/resources/app/README.md index 3cc3616..fd5491d 100644 --- a/dist/win-unpacked/resources/app/README.md +++ b/dist/win-unpacked/resources/app/README.md @@ -1,38 +1,78 @@ -# PTW Auto-Disconnect (Standalone GUI) +# PTW Auto-Disconnect -Runs your PTW monitor in a small desktop window **without opening Chrome**. It stays connected to `http://localhost:1947/_int_/sessions.html`, scans for the same keywords, and clicks Disconnect on matching rows. Logs and Monitor ON/OFF state are kept in the GUI. +Standalone desktop app that monitors your PTW sessions page and automatically disconnects sessions matching certain product/feature keywords. Runs in a small window **without opening Chrome**. + +## Features + +- **Auto-disconnect** — When Monitor is ON, scans the sessions table and clicks Disconnect on rows containing any of the target keywords. +- **Logged in** — Left panel shows who is logged in, grouped by user, with product/feature per session. +- **Activity log** — Right panel shows timestamps and disconnect/refresh events. +- **Config on startup** — On launch, checks `http://localhost:1947/_int_/config.html` and ensures **Table Rows per Page** is set to **100** (and submits if changed). +- **Stay awake** — While the app is running, prevents Windows from sleeping and the display from turning off. +- **One-click run** — Double-click **Start PTW Auto-Disconnect.vbs** (or the built exe) to run without opening a terminal. + +## Target keywords (disconnect when present) + +- PTW_DATAEXCHANGE +- PTW_ARC_FLASH +- PTW_DEVEVAL +- PTW_AFAULT +- PTW_DAPPER +- PTW_COOREVAL +- PTW_CAPTOR +- PTW_IEC_FAULT +- PTW_IEC61363 +- 19 +- 9 ## Requirements -- Node.js (LTS recommended) -- The sessions page must be available at `http://localhost:1947/_int_/sessions.html` (start your server first) +- **To run from source:** Node.js (LTS) and `npm install`. +- **Sessions server:** The app expects the sessions page at `http://localhost:1947/_int_/sessions.html` (and config at `http://localhost:1947/_int_/config.html`). Start your server first. -## Run +## Run from source ```bash npm install npm start ``` -## Build an executable (optional) +Or double-click **Start PTW Auto-Disconnect.vbs** (no terminal window). + +## Build executables ```bash npm run dist ``` -- **`dist\PTW Auto-Disconnect Setup 2.1.0.exe`** — Installer (Start Menu, etc.). -- **`dist\win-unpacked\`** — No-install: run **PTW Auto-Disconnect.exe** from this folder (all DLLs stay next to the exe; avoids ffmpeg.dll errors). +Output in **`dist`**: -To build and also create a single zip for the no-install version: +| Output | Description | +|--------|-------------| +| **PTW Auto-Disconnect Setup 2.1.0.exe** | Windows installer | +| **PTW Auto-Disconnect 2.1.0.exe** | Portable single exe (no install) | +| **win-unpacked/** | No-install folder; run **PTW Auto-Disconnect.exe** from inside (avoids ffmpeg path issues on some systems) | + +Optional: build and create a zip of the no-install folder: ```bash npm run dist:portable ``` -Then use **`dist\PTW Auto-Disconnect-no-install.zip`**: unzip anywhere and run **PTW Auto-Disconnect.exe** from the extracted folder. +Then use **`dist\PTW Auto-Disconnect-no-install.zip`** — unzip anywhere and run the exe from the extracted folder. -## Behavior +## Running on a new PC -- **Monitor ON/OFF** — Same as your script; when ON, the page is monitored and reloaded every 60 seconds. -- **Clear** — Clears the log display (state is still persisted until you clear). -- The page is loaded in a hidden webview inside the app; only the compact log + buttons window is visible. +- **From source:** Install Node.js, copy the project, run `npm install`, then `npm start` or the VBS launcher. +- **Built exe/installer:** Copy the installer or the **win-unpacked** folder (or the portable exe). No Node.js required. + +## Behavior summary + +- **Monitor ON/OFF** — Toggle monitoring; when ON, the sessions page is reloaded every 60 seconds and matching rows are disconnected. +- **Clear** — Clears the activity log display (persisted logs are cleared). +- **Config check** — On startup the app loads the config page, sets rows per page to 100 if needed, submits, then opens the sessions page. The activity log shows: *Config: rows per page already 100* or *Config: rows per page set to 100* (or a message if the input was not found). +- The sessions page is loaded in a hidden webview; only the compact GUI (panels + buttons) is visible. + +## License + +See [LICENSE](LICENSE). diff --git a/dist/win-unpacked/resources/app/inject.js b/dist/win-unpacked/resources/app/inject.js index a5197aa..121ffb9 100644 --- a/dist/win-unpacked/resources/app/inject.js +++ b/dist/win-unpacked/resources/app/inject.js @@ -4,7 +4,8 @@ const TARGET_KEYWORDS = [ 'PTW_DATAEXCHANGE', 'PTW_ARC_FLASH', 'PTW_DEVEVAL', 'PTW_AFAULT', - 'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363' + 'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363', + '19', '9' ]; window.__ptw_logQueue = window.__ptw_logQueue || []; diff --git a/inject.js b/inject.js index 6150f36..89c2494 100644 --- a/inject.js +++ b/inject.js @@ -4,7 +4,8 @@ const TARGET_KEYWORDS = [ 'PTW_DATAEXCHANGE', 'PTW_ARC_FLASH', 'PTW_DEVEVAL', 'PTW_AFAULT', - 'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363' + 'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363', + '19', '9' ]; window.__ptw_logQueue = window.__ptw_logQueue || [];