Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tutor-shot-extension
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramdayal Munda
tutor-shot-extension
Commits
3d0f3bca
Commit
3d0f3bca
authored
Nov 15, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added all events
parent
89279b51
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
20 deletions
+6
-20
background.js
background.js
+6
-9
content.js
content.js
+0
-11
No files found.
background.js
View file @
3d0f3bca
...
@@ -32,6 +32,7 @@ var getUserDetails = null
...
@@ -32,6 +32,7 @@ var getUserDetails = null
let
bodyObj
=
{
...
body
}
let
bodyObj
=
{
...
body
}
let
headerObj
=
{
let
headerObj
=
{
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'userid'
:
userDetails
?.
uid
,
...
headers
,
...
headers
,
}
}
fetch
(
url
,
{
fetch
(
url
,
{
...
@@ -56,6 +57,7 @@ var getUserDetails = null
...
@@ -56,6 +57,7 @@ var getUserDetails = null
let
bodyObj
=
{
...
body
}
let
bodyObj
=
{
...
body
}
let
headerObj
=
{
let
headerObj
=
{
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'userid'
:
userDetails
?.
uid
,
...
headers
,
...
headers
,
}
}
fetch
(
url
,
{
fetch
(
url
,
{
...
@@ -81,6 +83,7 @@ var getUserDetails = null
...
@@ -81,6 +83,7 @@ var getUserDetails = null
return
new
Promise
((
res
,
rej
)
=>
{
return
new
Promise
((
res
,
rej
)
=>
{
let
headerObj
=
{
let
headerObj
=
{
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'userid'
:
userDetails
?.
uid
,
...
obj
.
headers
,
...
obj
.
headers
,
}
}
fetch
(
url
,
{
fetch
(
url
,
{
...
@@ -105,6 +108,7 @@ var getUserDetails = null
...
@@ -105,6 +108,7 @@ var getUserDetails = null
return
new
Promise
((
res
,
rej
)
=>
{
return
new
Promise
((
res
,
rej
)
=>
{
let
headerObj
=
{
let
headerObj
=
{
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'userid'
:
userDetails
?.
uid
,
...
obj
.
headers
,
...
obj
.
headers
,
}
}
fetch
(
url
,
{
fetch
(
url
,
{
...
@@ -132,7 +136,6 @@ var getUserDetails = null
...
@@ -132,7 +136,6 @@ var getUserDetails = null
async
function
onMessage
(
request
,
sender
,
sendResponse
)
{
async
function
onMessage
(
request
,
sender
,
sendResponse
)
{
if
(
request
.
action
===
'login'
)
{
if
(
request
.
action
===
'login'
)
{
console
.
log
(
'B: to logged in'
,
request
.
userDetails
)
userDetails
=
request
.
userDetails
userDetails
=
request
.
userDetails
// check if credentials changed.
// check if credentials changed.
if
(
request
.
userDetails
.
email
!=
userDetails
.
email
)
{
if
(
request
.
userDetails
.
email
!=
userDetails
.
email
)
{
...
@@ -200,6 +203,7 @@ var getUserDetails = null
...
@@ -200,6 +203,7 @@ var getUserDetails = null
return
return
}
}
if
(
loggedIn
&&
request
.
action
===
'stopRecording'
)
{
if
(
loggedIn
&&
request
.
action
===
'stopRecording'
)
{
await
api
.
post
(
'/tutor-shot/finalize'
,
{
_id
:
tutorShotId
},
{
headers
:
{
userid
:
userDetails
.
uid
}
})
recording
=
false
;
recording
=
false
;
tutorShotId
=
null
tutorShotId
=
null
sendResponse
({
sendResponse
({
...
@@ -208,8 +212,6 @@ var getUserDetails = null
...
@@ -208,8 +212,6 @@ var getUserDetails = null
recording
,
recording
,
status
:
tutorShotId
?
(
recording
?
"recording"
:
"paused"
)
:
"stopped"
status
:
tutorShotId
?
(
recording
?
"recording"
:
"paused"
)
:
"stopped"
});
});
await
api
.
post
(
'/tutor-shot/finalize'
,
{
_id
:
tutorShotId
},
{
headers
:
{
userid
:
userDetails
.
uid
}
})
sendMessageToActiveTab
(
"recordingStopped"
)
sendMessageToActiveTab
(
"recordingStopped"
)
return
return
}
}
...
@@ -221,21 +223,19 @@ var getUserDetails = null
...
@@ -221,21 +223,19 @@ var getUserDetails = null
recording
,
recording
,
status
:
tutorShotId
?
(
recording
?
"recording"
:
"paused"
)
:
"stopped"
status
:
tutorShotId
?
(
recording
?
"recording"
:
"paused"
)
:
"stopped"
});
});
await
api
.
delete
(
'/tutor-shot/segments'
,
{
params
:
{
tutorShotOid
:
tutorShotId
}
})
sendMessageToActiveTab
(
"recordingRestarted"
)
sendMessageToActiveTab
(
"recordingRestarted"
)
return
return
}
}
if
(
request
.
action
===
'captureSS'
)
{
if
(
request
.
action
===
'captureSS'
)
{
if
(
!
loggedIn
)
{
if
(
!
loggedIn
)
{
console
.
log
(
'not logged in for SS'
);
return
;
return
;
}
}
if
(
!
recording
)
{
if
(
!
recording
)
{
console
.
log
(
'recording not started for SS'
);
return
;
return
;
}
}
if
(
!
tutorShotId
)
{
if
(
!
tutorShotId
)
{
console
.
log
(
'how to set not created'
);
return
return
}
}
chrome
.
tabs
.
query
({
active
:
true
,
currentWindow
:
true
},
function
(
tabs
)
{
chrome
.
tabs
.
query
({
active
:
true
,
currentWindow
:
true
},
function
(
tabs
)
{
...
@@ -252,9 +252,7 @@ var getUserDetails = null
...
@@ -252,9 +252,7 @@ var getUserDetails = null
}
}
// to send message to the content instance of the
// to send message to the content instance of the
chrome
.
tabs
.
sendMessage
(
activeTab
.
id
,
message
);
chrome
.
tabs
.
sendMessage
(
activeTab
.
id
,
message
);
console
.
log
(
'to take screenshot'
,
message
)
let
data
=
await
api
.
post
(
'/tutor-shot/screen-shot'
,
message
)
let
data
=
await
api
.
post
(
'/tutor-shot/screen-shot'
,
message
)
console
.
log
(
'sent SS to server'
,
data
)
})
})
}
}
})
})
...
@@ -288,7 +286,6 @@ var getUserDetails = null
...
@@ -288,7 +286,6 @@ var getUserDetails = null
status
:
tutorShotId
?
(
recording
?
"recording"
:
"paused"
)
:
"stopped"
,
status
:
tutorShotId
?
(
recording
?
"recording"
:
"paused"
)
:
"stopped"
,
message
:
messageObj
message
:
messageObj
}
}
console
.
log
(
'sending message:'
,
message
)
chrome
.
tabs
.
sendMessage
(
activeTab
.
id
,
message
);
chrome
.
tabs
.
sendMessage
(
activeTab
.
id
,
message
);
}
}
})
})
...
...
content.js
View file @
3d0f3bca
...
@@ -188,7 +188,6 @@ async function login() {
...
@@ -188,7 +188,6 @@ async function login() {
email
:
localStorage
.
getItem
(
'email'
)
email
:
localStorage
.
getItem
(
'email'
)
}
}
if
(
userDetails
?.
uid
||
userDetails
?.
email
)
{
// can login
if
(
userDetails
?.
uid
||
userDetails
?.
email
)
{
// can login
console
.
log
(
'logged in'
,
userDetails
)
chrome
.
runtime
.
sendMessage
({
action
:
"login"
,
userDetails
})
chrome
.
runtime
.
sendMessage
({
action
:
"login"
,
userDetails
})
}
}
}
}
...
@@ -201,7 +200,6 @@ async function getCaptureData() {
...
@@ -201,7 +200,6 @@ async function getCaptureData() {
}
}
function
reRenderFloatingBar
(
data
)
{
function
reRenderFloatingBar
(
data
)
{
console
.
log
(
'reRenderFloatingBar'
,
data
)
if
(
data
)
{
if
(
data
)
{
if
(
data
.
status
==
'stopped'
)
{
if
(
data
.
status
==
'stopped'
)
{
floatingBar
.
remove
()
floatingBar
.
remove
()
...
@@ -216,7 +214,6 @@ function reRenderFloatingBar(data) {
...
@@ -216,7 +214,6 @@ function reRenderFloatingBar(data) {
}
}
if
(
!
btn
.
capture
)
{
if
(
!
btn
.
capture
)
{
btn
.
capture
=
document
.
querySelector
(
'[tutor-shot="capture-btn"]'
)
btn
.
capture
=
document
.
querySelector
(
'[tutor-shot="capture-btn"]'
)
console
.
log
(
'take screen shot'
)
}
}
if
(
!
btn
.
playText
)
btn
.
playText
=
document
.
querySelector
(
'[tutor-shot="play-text"]'
)
if
(
!
btn
.
playText
)
btn
.
playText
=
document
.
querySelector
(
'[tutor-shot="play-text"]'
)
if
(
!
btn
.
pause
)
{
if
(
!
btn
.
pause
)
{
...
@@ -238,7 +235,6 @@ function reRenderFloatingBar(data) {
...
@@ -238,7 +235,6 @@ function reRenderFloatingBar(data) {
if
(
!
btn
.
counter
)
btn
.
counter
=
document
.
querySelector
(
'[tutor-shot="counter"]'
)
if
(
!
btn
.
counter
)
btn
.
counter
=
document
.
querySelector
(
'[tutor-shot="counter"]'
)
if
(
data
?.
hasOwnProperty
(
'imageNumber'
))
{
if
(
data
?.
hasOwnProperty
(
'imageNumber'
))
{
console
.
log
(
'set'
,
data
.
imageNumber
,
btn
.
counter
.
innerHTML
)
btn
.
counter
.
innerHTML
=
`
${
data
.
imageNumber
}
`
btn
.
counter
.
innerHTML
=
`
${
data
.
imageNumber
}
`
if
(
data
.
imageNumber
<=
0
)
btn
.
counter
.
style
.
display
=
'none'
if
(
data
.
imageNumber
<=
0
)
btn
.
counter
.
style
.
display
=
'none'
else
btn
.
counter
.
style
.
display
=
'flex'
else
btn
.
counter
.
style
.
display
=
'flex'
...
@@ -305,15 +301,12 @@ window.addEventListener('mousedown', async function (e) {
...
@@ -305,15 +301,12 @@ window.addEventListener('mousedown', async function (e) {
// content.js
// content.js
chrome
.
runtime
.
onMessage
.
addListener
(
async
function
(
message
,
sender
,
sendResponse
)
{
chrome
.
runtime
.
onMessage
.
addListener
(
async
function
(
message
,
sender
,
sendResponse
)
{
console
.
log
(
'message received'
,
message
)
if
(
message
.
action
==
'tabChanged'
)
{
if
(
message
.
action
==
'tabChanged'
)
{
// console.log('tabChanged', message)
// console.log('tabChanged', message)
}
}
if
(
message
.
status
)
{
if
(
message
.
status
)
{
console
.
log
(
'got message status'
,
message
)
}
}
if
(
message
.
action
==
'SSCaptured'
)
{
if
(
message
.
action
==
'SSCaptured'
)
{
console
.
log
(
'to capture SS'
)
// let data = await api.post("/tutor-shot/screen-shot", message)
// let data = await api.post("/tutor-shot/screen-shot", message)
}
}
let
data
=
await
getCaptureData
()
let
data
=
await
getCaptureData
()
...
@@ -332,7 +325,6 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
...
@@ -332,7 +325,6 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
startingOverlay
.
remove
()
startingOverlay
.
remove
()
return
return
}
}
console
.
log
(
'counter'
,
counter
)
startingOverlay
.
innerHTML
=
`
startingOverlay
.
innerHTML
=
`
<div>
<div>
Click on the webpage to take screenshot
Click on the webpage to take screenshot
...
@@ -377,8 +369,6 @@ async function resumeRecording() {
...
@@ -377,8 +369,6 @@ async function resumeRecording() {
async
function
stopRecording
()
{
async
function
stopRecording
()
{
try
{
try
{
console
.
log
(
'to stop recording'
)
// await api.post('/tutor-shot/finalize', { _id: tutorShotOid }, { headers: { userid: userDetails.uid } })
await
chrome
.
runtime
.
sendMessage
({
action
:
"stopRecording"
})
await
chrome
.
runtime
.
sendMessage
({
action
:
"stopRecording"
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
...
@@ -387,7 +377,6 @@ async function stopRecording() {
...
@@ -387,7 +377,6 @@ async function stopRecording() {
async
function
restartRecording
()
{
async
function
restartRecording
()
{
try
{
try
{
await
api
.
delete
(
'/tutor-shot/segments'
,
{
params
:
{
tutorShotOid
:
tutorShotOid
}
})
await
chrome
.
runtime
.
sendMessage
({
action
:
"restartRecording"
})
await
chrome
.
runtime
.
sendMessage
({
action
:
"restartRecording"
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment