Skip to content

Commit 9b21ea1

Browse files
committed
local update
1 parent c860e80 commit 9b21ea1

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

src/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<a id="btnAll">All-time</a>
3333
<a id="btnByDays">By days</a>
3434
<a id="settings">Settings</a>
35+
<a id="btnSendData">Send Data</a>
36+
3537
<div id='hintForUsers' class="hint-for-settings hide">
3638
<div id='closeHintBtn' class="close-hint"></div>
3739
<p class="title-block">In Web Activity Time Tracker you can:</p>
@@ -119,4 +121,6 @@
119121
<script src="scripts/storage.js"></script>
120122
<script src="scripts/common.js"></script>
121123
<script src="scripts/ui.js"></script>
122-
<script src="scripts/webact.js"></script>
124+
<script src="scripts/webact.js"></script>
125+
126+
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

src/scripts/background.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,4 +473,39 @@ loadPermissions();
473473
addListener();
474474
loadAddDataFromStorage();
475475
updateSummaryTime();
476-
updateStorage();
476+
updateStorage();
477+
478+
479+
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
480+
console.log("chrome listener triggered in background.js")
481+
if (request.action === "sendBrowserActivityData") {
482+
console.log("triggering sendBrowserActivityData function");
483+
sendBrowserActivityData();
484+
}
485+
});
486+
487+
488+
function sendBrowserActivityData() {
489+
// const backendUrl = "https://your-backend-url.com/api/browser-activity";
490+
console.log(tabs)
491+
492+
const browserActivityData = tabs.map(tab => {
493+
return {
494+
url: tab.url,
495+
days: tab.days.map(day => {
496+
return {
497+
date: day.date,
498+
summary: day.summary,
499+
time: day.time
500+
};
501+
})
502+
};
503+
});
504+
505+
console.log(browserActivityData);
506+
507+
// axios.post(backendUrl, browserActivityData)
508+
// .then(response => console.log("Data sent successfully:", response.data))
509+
// .catch(error => console.error("Error sending data:", error));
510+
}
511+

src/scripts/webact.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ document.addEventListener('DOMContentLoaded', function () {
122122
window.open(chrome.runtime.getURL('options.html'));
123123
}
124124
});
125+
126+
document.getElementById("btnSendData").addEventListener("click", function () {
127+
console.log("button clicked here");
128+
chrome.runtime.sendMessage({ action: "sendBrowserActivityData" });
129+
});
130+
125131
});
126132

127133
firstInitPage();
@@ -556,4 +562,6 @@ function fillValuesForBlockWithInActiveDay(prefix, dayValue, timeValue, flag) {
556562
document.getElementById(prefix).value = dayValue;
557563
document.getElementById(prefix + 'Time').value = timeValue;
558564
}
559-
}
565+
}
566+
567+

0 commit comments

Comments
 (0)