Răsfoiți Sursa

LV Extract: extn for copying measurements from libre ui

Vijayakrishnan Krishnan 5 zile în urmă
părinte
comite
4f0bec9e69

+ 4 - 0
ext-utils/lvextract/README.md

@@ -0,0 +1,4 @@
+# LV Extract Chrome Extension
+
+Chrome extension to help copy daily summary in bulk for a month from LibreView UI
+

+ 1 - 0
ext-utils/lvextract/background.js

@@ -0,0 +1 @@
+// background.js required by manifest, but not used in this extension 

+ 56 - 0
ext-utils/lvextract/content.js

@@ -0,0 +1,56 @@
+(function () {
+
+    if (window.top !== window.self) {
+
+        const onCopyClicked = function (_from) {
+            const values = [], year = $('#dateTag').text().split(' ')[1];
+            $('#monthlySummaryChartArea text').each(function () {
+                if ($(this).attr('id') && $(this).attr('id').indexOf('averageGlucoseValue') !== -1) {
+                    const parts = $(this).attr('id').split('-');
+                    const day = +parts[2];
+                    if(day >= _from) {
+                        values.push({
+                            value: $(this).text(),
+                            day: parts[2],
+                            month: parts[1],
+                            year: year,
+                        });
+                    }
+                }
+            });
+            const json = JSON.stringify(values);
+            navigator.clipboard.writeText(json);
+            alert('Copied to clipboard');
+        }
+
+        // try and detect #monthlySummaryReportSpace
+        const $monthlySummaryReportSpace = $('#monthlySummaryReportSpace');
+        if ($monthlySummaryReportSpace.length) {
+
+            const copyAll = $('<span class="copy all"><b>Copy All</b></span>')
+                .click(function() {
+                    onCopyClicked(1);
+                });
+
+            const copyFrom = $('<span class="copy from"><b>Copy From</b></span>')
+                .click(function() {
+                    let fromDay = prompt('From date (just the day, for ex: 7):');
+                    fromDay = $.trim(fromDay);
+                    if(isNaN(fromDay)) {
+                        alert('Not a valid day');
+                        return;
+                    }
+                    fromDay = +fromDay;
+                    onCopyClicked(fromDay);
+                });
+
+            jQuery('<div/>').html('Auto-detected Monthly Summary - ')
+                .addClass('lv-ms-detected')
+                .append(copyAll)
+                .append('&nbsp;-&nbsp;')
+                .append(copyFrom)
+                .appendTo($monthlySummaryReportSpace);
+        }
+    }
+
+})(); 

Fișier diff suprimat deoarece este prea mare
+ 1 - 0
ext-utils/lvextract/jquery.js


+ 28 - 0
ext-utils/lvextract/manifest.json

@@ -0,0 +1,28 @@
+{
+  "manifest_version": 3,
+  "name": "LV Extract",
+  "version": "1.0",
+  "description": "Extract Measurements from LibreView.",
+  "permissions": ["scripting"],
+  "host_permissions": ["<all_urls>"],
+  "background": {
+    "service_worker": "background.js"
+  },
+  "content_scripts": [
+    {
+      "matches": ["*://*.libreview.com/*", "*://*.leadershiphealth.local/*", "*://*.mindbodycbt.com/*", "*://*.libreview.io/*"],
+      "js": ["jquery.js", "content.js"],
+      "css": ["style.css"],
+      "all_frames": true
+    }
+  ],
+  "action": {
+    "default_title": "LV Extract"
+  },
+  "web_accessible_resources": [
+    {
+      "resources": ["sidebar.html"],
+      "matches": ["<all_urls>"]
+    }
+  ]
+}

+ 10 - 0
ext-utils/lvextract/sidebar.html

@@ -0,0 +1,10 @@
+<div class="lv-extract-sidebar-header">
+    LV Extract
+    <div class="toggle-sidebar lv-open">Open</div>
+    <div class="toggle-sidebar lv-close">Close</div>
+</div>
+<div class="lv-extract-sidebar-content">
+    <div id="lv-extract-sidebar-content-header">
+        <h2>Extract Measurements</h2>
+    </div>
+</div>

+ 19 - 0
ext-utils/lvextract/style.css

@@ -0,0 +1,19 @@
+#monthlySummaryReportSpace {
+  outline: 9px solid #00800057;
+}
+
+.lv-ms-detected {
+  font-size: 12px;
+  color: #008000;
+  position: absolute;
+  z-index: 999999;
+  top: 8px;
+  right: 8px;
+  font-family: sans-serif;
+  font-weight: normal;
+  background: #f9efe4;
+  padding: 4px 7px;
+  border-bottom-left-radius: 3px;
+  cursor: pointer;
+}
+

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff