-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinject.js
47 lines (39 loc) · 1.2 KB
/
inject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
console.log("Extension Started !!!");
var interval = setInterval(function(){
if (registerCodeBoxEventListener()){
clearInterval(interval);
}
},500)
// Function to register the event listener
function registerCodeBoxEventListener() {
var codeBox = document.querySelector("div.view-lines.monaco-mouse-cursor-text");
if (codeBox){
// Add event listener for click
codeBox.addEventListener("click", codeBoxClickListener);
return true
}
return false
}
// Click event listener for the code box
function codeBoxClickListener() {
logUserAction();
startTimer();
// Remove the event listener after it has been called
var codeBox = document.querySelector("div.view-lines.monaco-mouse-cursor-text");
codeBox.removeEventListener("click", codeBoxClickListener);
}
// Event handler function
function logUserAction() {
console.log("User started coding");
}
// Timer function
function startTimer() {
try {
const cssSelector = "div[class='css-0'] > div";
const element = document.querySelector(cssSelector);
console.log("Starting Timer");
element.click();
} catch (error) {
console.error("An error occurred while starting the timer:", error);
}
}