diff --git a/README.md b/README.md index 878a134..36d90e0 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ The setup page has these steps with your URL filled in. 3. From the Violentmonkey toolbar menu, choose **Set server and API key**. Enter `https://www.adam-french.co.uk/tracker` and the key. 4. Other menu commands toggle full URLs (`attrs.url`, which also splits intervals per page) and page titles (`attrs.title`), set a regexp of hosts to ignore, change the idle timeout, and show the queue and last upload result. -Closed intervals are queued in the script's storage and uploaded every minute by one tab at a time. If a tab is closed or crashes mid-interval, another tab recovers its last checkpoint (at most 5s lost). The script can't see browser pages such as `about:`, `chrome://` or the new tab page, extension stores, or the built-in PDF viewer, so time there isn't recorded. The Hyprland agent still counts it as browser `app_focus`. +Closed intervals are queued in the script's storage and uploaded every minute by one tab at a time. If a tab is closed or crashes mid-interval, another tab recovers its last checkpoint (at most 5s lost). It runs on every `http`/`https` page and on local `file://` pages, which are labelled `file` (in Chrome, enable **Allow access to file URLs** for Violentmonkey). It can't see browser pages such as `about:`, `chrome://` or the new tab page, extension stores, or the built-in PDF viewer, so time there isn't recorded. The Hyprland agent still counts it as browser `app_focus`. ## Apple Health diff --git a/internal/web/setup.html b/internal/web/setup.html index e7205be..0bd0000 100644 --- a/internal/web/setup.html +++ b/internal/web/setup.html @@ -51,7 +51,7 @@
trk_…  (generate a key above)
  • Check it with Status / upload now in the same menu. Uploads happen every minute.
  • -

    The menu also turns full URLs and page titles on or off (both off by default), sets hosts to ignore, and changes the idle timeout. about: pages, the new tab page, extension stores and the PDF viewer can't run scripts, so they aren't recorded; Hyprland still counts them as browser time.

    +

    The menu also turns full URLs and page titles on or off (both off by default), sets hosts to ignore, and changes the idle timeout. It runs on every web page and on local file:// pages (labelled file; in Chrome, turn on Allow access to file URLs in Violentmonkey's extension details). Browsers block all extensions on about: pages, the new tab page, extension stores and the PDF viewer, so those aren't recorded; Hyprland still counts them as browser time.

    diff --git a/internal/web/tracker.user.js b/internal/web/tracker.user.js index 26d3a9b..fb8c5d1 100644 --- a/internal/web/tracker.user.js +++ b/internal/web/tracker.user.js @@ -1,9 +1,10 @@ // ==UserScript== // @name Activity Tracker // @namespace adam-french.co.uk/activity-tracker -// @version 1.0.0 +// @version 1.1.0 // @description Records time spent on the focused tab and uploads it to the activity tracker. // @match *://*/* +// @match file:///* // @noframes // @run-at document-start // @grant GM_xmlhttpRequest @@ -72,7 +73,7 @@ if (document.visibilityState !== 'visible' || !document.hasFocus()) return null; if (mediaPlaying()) lastActive = now; if (now - lastActive > c.idleMinutes * 60e3) return null; - const host = location.hostname.replace(/^www\./, ''); + const host = location.protocol === 'file:' ? 'file' : location.hostname.replace(/^www\./, ''); if (!host) return null; if (c.ignore) { try { if (new RegExp(c.ignore, 'i').test(host)) return null; } catch (_) { /* bad regexp: ignore nothing */ }