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
e4f159e3
Commit
e4f159e3
authored
Mar 02, 2024
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removing events for getting generated video response
parent
fcff1848
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
40 deletions
+43
-40
background.js
background.js
+10
-7
content.js
content.js
+31
-31
manifest.json
manifest.json
+1
-1
popup.js
popup.js
+1
-1
No files found.
background.js
View file @
e4f159e3
...
@@ -7,7 +7,6 @@ var getUserDetails = null
...
@@ -7,7 +7,6 @@ var getUserDetails = null
var
recording
=
false
;
var
recording
=
false
;
var
loggedIn
=
false
;
var
loggedIn
=
false
;
var
userDetails
=
{}
var
userDetails
=
{}
var
generatingVideo
=
false
;
function
setData
(
key
,
value
,
callback
)
{
function
setData
(
key
,
value
,
callback
)
{
...
@@ -53,7 +52,7 @@ var getUserDetails = null
...
@@ -53,7 +52,7 @@ var getUserDetails = null
})
})
function
getStatus
(){
function
getStatus
(){
return
tutorShotId
?
(
generatingVideo
?
'generatingVideo'
:
recording
?
"recording"
:
"paused"
):
"stopped"
return
tutorShotId
?
(
recording
?
"recording"
:
"paused"
):
"stopped"
}
}
...
@@ -260,7 +259,7 @@ var getUserDetails = null
...
@@ -260,7 +259,7 @@ var getUserDetails = null
return
return
}
}
if
(
loggedIn
&&
request
.
action
===
'stopRecording'
)
{
if
(
loggedIn
&&
request
.
action
===
'stopRecording'
)
{
generatingVideo
=
true
console
.
log
(
'to stop recording'
)
recording
=
false
;
recording
=
false
;
sendResponse
({
sendResponse
({
userDetails
,
userDetails
,
...
@@ -268,21 +267,20 @@ var getUserDetails = null
...
@@ -268,21 +267,20 @@ var getUserDetails = null
recording
,
recording
,
status
:
getStatus
()
status
:
getStatus
()
});
});
console
.
log
(
'sending generatingVideo message, '
)
sendMessageToActiveTab
(
"generatingVideo"
)
sendMessageToActiveTab
(
"generatingVideo"
)
console
.
log
(
'sent generatingVideo message, '
)
await
api
.
post
(
'/tutor-shot/finalize'
,
{
_id
:
tutorShotId
},
{
headers
:
{
userid
:
userDetails
.
uid
}
})
await
api
.
post
(
'/tutor-shot/finalize'
,
{
_id
:
tutorShotId
},
{
headers
:
{
userid
:
userDetails
.
uid
}
})
generatingVideo
=
false
tutorShotId
=
null
tutorShotId
=
null
sendMessageToActiveTab
(
"recordingStopped"
)
setData
(
"recording"
,
false
)
setData
(
"recording"
,
false
)
setData
(
"imageNumber"
,
0
)
setData
(
"imageNumber"
,
0
)
setData
(
"tutorShotId"
,
tutorShotId
)
setData
(
"tutorShotId"
,
null
)
imageNumber
=
0
;
imageNumber
=
0
;
return
return
}
}
if
(
request
.
action
===
'logout'
)
{
if
(
request
.
action
===
'logout'
)
{
loggedIn
=
false
;
loggedIn
=
false
;
recording
=
false
;
recording
=
false
;
generatingVideo
=
false
;
userDetails
=
{};
userDetails
=
{};
tutorShotId
=
null
;
tutorShotId
=
null
;
imageNumber
=
0
;
imageNumber
=
0
;
...
@@ -373,7 +371,12 @@ var getUserDetails = null
...
@@ -373,7 +371,12 @@ var getUserDetails = null
status
:
getStatus
(),
status
:
getStatus
(),
message
:
messageObj
message
:
messageObj
}
}
try
{
chrome
.
tabs
.
sendMessage
(
activeTab
?.
id
,
message
);
chrome
.
tabs
.
sendMessage
(
activeTab
?.
id
,
message
);
}
catch
(
err
){
console
.
log
(
'error while sending data'
,
activeTab
,
message
)
console
.
log
(
err
)
}
}
}
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
...
content.js
View file @
e4f159e3
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
var
loggedIn
=
false
;
var
loggedIn
=
false
;
var
floatingBar
=
null
;
var
floatingBar
=
null
;
var
startingOverlay
=
null
;
var
startingOverlay
=
null
;
var
finalizingOverlay
=
null
;
var
overlayInterval
=
null
;
var
overlayInterval
=
null
;
const
origin
=
"http://localhost:3039"
const
origin
=
"http://localhost:3039"
var
userDetails
=
{};
var
userDetails
=
{};
...
@@ -11,21 +12,21 @@ var btn = {};
...
@@ -11,21 +12,21 @@ var btn = {};
var
tutorShotOid
=
null
;
var
tutorShotOid
=
null
;
var
containerDiv
;
var
containerDiv
;
var
sr
;
var
sr
;
var
webpageObserver
=
{
disconnect
()
{
}
}
var
webpageObserver
=
{
disconnect
()
{
}
}
!
(
async
function
()
{
!
(
async
function
()
{
if
(
window
.
origin
==
origin
){
login
()
}
if
(
window
.
origin
==
origin
)
{
login
()
}
else
{
else
{
window
.
clearInterval
(
window
.
tutorShotInterval
)
window
.
clearInterval
(
window
.
tutorShotInterval
)
window
.
tutorShotInterval
=
setInterval
(
async
()
=>
{
window
.
tutorShotInterval
=
setInterval
(
async
()
=>
{
try
{
try
{
let
data
=
await
getCaptureData
()
let
data
=
await
getCaptureData
()
reRenderFloatingBar
(
data
)
reRenderFloatingBar
(
data
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
}
}
},
1000
)
},
1000
)
}
}
containerDiv
=
document
.
createElement
(
'div'
)
containerDiv
=
document
.
createElement
(
'div'
)
...
@@ -165,7 +166,6 @@ var webpageObserver = { disconnect(){} }
...
@@ -165,7 +166,6 @@ var webpageObserver = { disconnect(){} }
<div class="counter-count" tutor-shot="counter" style="display:none;"></div>
<div class="counter-count" tutor-shot="counter" style="display:none;"></div>
<div class="logo">
<div class="logo">
<img tutor-shot="main-logo" class="logo-img" src="
${
origin
}
/assets/images/tutor-shot-48.png" width="40">
<img tutor-shot="main-logo" class="logo-img" src="
${
origin
}
/assets/images/tutor-shot-48.png" width="40">
<img tutor-shot="generating-video" class="logo-img" src="
${
origin
}
/assets/images/logo-loader.gif" width="40">
</div>
</div>
<div class="content">
<div class="content">
<div class="item" tutor-shot="play-btn">
<div class="item" tutor-shot="play-btn">
...
@@ -237,6 +237,7 @@ async function getCaptureData() {
...
@@ -237,6 +237,7 @@ 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'
)
{
containerDiv
.
remove
()
containerDiv
.
remove
()
...
@@ -253,9 +254,6 @@ function reRenderFloatingBar(data) {
...
@@ -253,9 +254,6 @@ function reRenderFloatingBar(data) {
if
(
!
btn
.
mainLogo
)
{
if
(
!
btn
.
mainLogo
)
{
btn
.
mainLogo
=
sr
.
querySelector
(
'[tutor-shot="main-logo"]'
)
btn
.
mainLogo
=
sr
.
querySelector
(
'[tutor-shot="main-logo"]'
)
}
}
if
(
!
btn
.
generatingVideo
)
{
btn
.
generatingVideo
=
sr
.
querySelector
(
'[tutor-shot="generating-video"]'
)
}
if
(
!
btn
.
capture
)
{
if
(
!
btn
.
capture
)
{
btn
.
capture
=
sr
.
querySelector
(
'[tutor-shot="capture-btn"]'
)
btn
.
capture
=
sr
.
querySelector
(
'[tutor-shot="capture-btn"]'
)
}
}
...
@@ -288,7 +286,6 @@ function reRenderFloatingBar(data) {
...
@@ -288,7 +286,6 @@ function reRenderFloatingBar(data) {
btn
.
pause
.
style
.
display
=
'none'
btn
.
pause
.
style
.
display
=
'none'
btn
.
stop
.
style
.
display
=
'flex'
btn
.
stop
.
style
.
display
=
'flex'
btn
.
restart
.
style
.
display
=
'flex'
btn
.
restart
.
style
.
display
=
'flex'
btn
.
generatingVideo
.
style
.
display
=
'none'
btn
.
mainLogo
.
style
.
display
=
'block'
btn
.
mainLogo
.
style
.
display
=
'block'
}
}
else
if
(
data
?.
status
==
'recording'
)
{
else
if
(
data
?.
status
==
'recording'
)
{
...
@@ -296,24 +293,14 @@ function reRenderFloatingBar(data) {
...
@@ -296,24 +293,14 @@ function reRenderFloatingBar(data) {
btn
.
pause
.
style
.
display
=
'flex'
btn
.
pause
.
style
.
display
=
'flex'
btn
.
restart
.
style
.
display
=
'flex'
btn
.
restart
.
style
.
display
=
'flex'
btn
.
stop
.
style
.
display
=
'flex'
btn
.
stop
.
style
.
display
=
'flex'
btn
.
generatingVideo
.
style
.
display
=
'none'
btn
.
mainLogo
.
style
.
display
=
'block'
btn
.
mainLogo
.
style
.
display
=
'block'
// btn.capture.style.display = 'flex'
// btn.capture.style.display = 'flex'
}
}
else
if
(
data
?.
status
==
'generatingVideo'
)
{
btn
.
play
.
style
.
display
=
'none'
btn
.
pause
.
style
.
display
=
'none'
btn
.
stop
.
style
.
display
=
'none'
btn
.
restart
.
style
.
display
=
'none'
btn
.
generatingVideo
.
style
.
display
=
'block'
btn
.
mainLogo
.
style
.
display
=
'none'
}
else
{
// stopped
else
{
// stopped
btn
.
play
.
style
.
display
=
'flex'
btn
.
play
.
style
.
display
=
'flex'
btn
.
pause
.
style
.
display
=
'none'
btn
.
pause
.
style
.
display
=
'none'
btn
.
stop
.
style
.
display
=
'none'
btn
.
stop
.
style
.
display
=
'none'
btn
.
restart
.
style
.
display
=
'none'
btn
.
restart
.
style
.
display
=
'none'
btn
.
generatingVideo
.
style
.
display
=
'none'
btn
.
mainLogo
.
style
.
display
=
'block'
btn
.
mainLogo
.
style
.
display
=
'block'
}
}
}
}
...
@@ -346,8 +333,8 @@ window.addEventListener('mousedown', async function (e) {
...
@@ -346,8 +333,8 @@ window.addEventListener('mousedown', async function (e) {
url
:
location
.
href
,
url
:
location
.
href
,
origin
:
location
.
origin
,
origin
:
location
.
origin
,
}
}
let
newLineBreakIndex
=
captureInfo
.
text
.
search
(
'
\
n'
)
let
newLineBreakIndex
=
captureInfo
.
text
.
search
(
'
\
n'
)
if
(
newLineBreakIndex
!=
-
1
)
captureInfo
.
text
=
captureInfo
.
text
.
slice
(
0
,
newLineBreakIndex
)
if
(
newLineBreakIndex
!=
-
1
)
captureInfo
.
text
=
captureInfo
.
text
.
slice
(
0
,
newLineBreakIndex
)
// console.log('sending capture info', captureInfo)
// console.log('sending capture info', captureInfo)
chrome
.
runtime
.
sendMessage
({
action
:
"captureSS"
,
captureInfo
})
chrome
.
runtime
.
sendMessage
({
action
:
"captureSS"
,
captureInfo
})
let
data
=
await
getCaptureData
()
let
data
=
await
getCaptureData
()
...
@@ -357,6 +344,7 @@ window.addEventListener('mousedown', async function (e) {
...
@@ -357,6 +344,7 @@ 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
(
'getting message'
)
if
(
message
.
action
==
'tabChanged'
)
{
if
(
message
.
action
==
'tabChanged'
)
{
// console.log('tabChanged', message)
// console.log('tabChanged', message)
}
}
...
@@ -396,14 +384,26 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
...
@@ -396,14 +384,26 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
}
}
else
if
(
message
.
message
==
'generatingVideo'
)
{
else
if
(
message
.
message
==
'generatingVideo'
)
{
reRenderFloatingBar
(
data
)
console
.
log
(
'generating Video'
)
}
finalizingOverlay
=
document
.
createElement
(
'div'
)
else
if
(
message
.
message
==
'recordingStopped'
)
{
finalizingOverlay
.
setAttribute
(
'class'
,
'tutor-shot-overlay'
)
if
(
window
.
location
.
href
==
`
${
origin
}
/tutor-shot-list`
){
sr
.
append
(
finalizingOverlay
)
finalizingOverlay
.
innerHTML
=
`
<div>
Your video is being saved.
</div>
`
setTimeout
(()
=>
{
finalizingOverlay
.
remove
()
if
(
window
.
location
.
href
==
`
${
origin
}
/tutor-shot-list`
)
{
window
.
location
.
reload
()
window
.
location
.
reload
()
}
else
{
}
else
{
window
.
open
(
`
${
origin
}
/tutor-shot-list`
)
window
.
open
(
`
${
origin
}
/tutor-shot-list`
)
}
}
reRenderFloatingBar
(
data
)
},
2000
)
reRenderFloatingBar
(
data
)
}
}
});
});
...
@@ -412,7 +412,7 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
...
@@ -412,7 +412,7 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
async
function
startRecording
()
{
async
function
startRecording
()
{
try
{
try
{
await
getCaptureData
();
await
getCaptureData
();
let
{
data
}
=
await
api
.
post
(
'/tutor-shot'
,
{
title
:
"
Some random t
itle"
},
{
headers
:
{
userId
:
userDetails
.
uid
}
})
let
{
data
}
=
await
api
.
post
(
'/tutor-shot'
,
{
title
:
"
No T
itle"
},
{
headers
:
{
userId
:
userDetails
.
uid
}
})
if
(
data
.
success
)
{
if
(
data
.
success
)
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"startRecording"
,
tutorShotId
:
data
.
tutorShot
.
_id
})
await
chrome
.
runtime
.
sendMessage
({
action
:
"startRecording"
,
tutorShotId
:
data
.
tutorShot
.
_id
})
}
}
...
...
manifest.json
View file @
e4f159e3
{
{
"manifest_version"
:
3
,
"manifest_version"
:
3
,
"name"
:
"Tutor Shot Local"
,
"name"
:
"Tutor Shot Local"
,
"version"
:
"1.
8
"
,
"version"
:
"1.
10
"
,
"description"
:
"Capture web-page screenshots instantly with a single click. They're saved to your account at http://localhost:3039."
,
"description"
:
"Capture web-page screenshots instantly with a single click. They're saved to your account at http://localhost:3039."
,
"permissions"
:
[
"permissions"
:
[
"activeTab"
,
"activeTab"
,
...
...
popup.js
View file @
e4f159e3
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
}
}
inProgress
=
true
inProgress
=
true
try
{
try
{
let
{
data
}
=
await
api
.
post
(
'/tutor-shot'
,
{
title
:
"
Some random t
itle"
},
{
headers
:
{
userId
:
userDetails
.
uid
}
}
)
let
{
data
}
=
await
api
.
post
(
'/tutor-shot'
,
{
title
:
"
No T
itle"
},
{
headers
:
{
userId
:
userDetails
.
uid
}
}
)
if
(
data
.
success
){
if
(
data
.
success
){
chrome
.
runtime
.
sendMessage
({
action
:
"startRecording"
,
tutorShotId
:
data
.
tutorShot
.
_id
},
async
function
(
response
)
{
chrome
.
runtime
.
sendMessage
({
action
:
"startRecording"
,
tutorShotId
:
data
.
tutorShot
.
_id
},
async
function
(
response
)
{
recording
=
response
.
recording
recording
=
response
.
recording
...
...
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