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
f86b8529
Commit
f86b8529
authored
Nov 14, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restart recording feature added
parent
6a3f96aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
37 deletions
+74
-37
background.js
background.js
+11
-0
content.js
content.js
+63
-37
calibri-regular.ttf
fonts/calibri-regular.ttf
+0
-0
No files found.
background.js
View file @
f86b8529
...
@@ -92,6 +92,17 @@ var getUserDetails = null
...
@@ -92,6 +92,17 @@ var getUserDetails = null
sendMessageToActiveTab
(
"recordingStopped"
)
sendMessageToActiveTab
(
"recordingStopped"
)
return
return
}
}
if
(
loggedIn
&&
request
.
action
===
'restartRecording'
)
{
imageNumber
=
0
;
sendResponse
({
userDetails
,
loggedIn
,
recording
,
status
:
tutorShotId
?(
recording
?
"recording"
:
"paused"
):
"stopped"
});
sendMessageToActiveTab
(
"recordingRestarted"
)
return
}
if
(
request
.
action
===
'captureSS'
)
{
if
(
request
.
action
===
'captureSS'
)
{
if
(
!
loggedIn
)
{
if
(
!
loggedIn
)
{
...
...
content.js
View file @
f86b8529
...
@@ -10,11 +10,7 @@ var userDetails = {};
...
@@ -10,11 +10,7 @@ var userDetails = {};
var
btn
=
{}
var
btn
=
{}
!
(
async
function
()
{
!
(
async
function
()
{
// this is load custom font
loadFont
(
'tutor-shot-calibri'
,
`
${
origin
}
/assets/fonts/calibri-regular.ttf`
,
'truetype'
)
let
customFont
=
new
FontFace
(
'tutor-shot-calibri'
,
`url(
${
origin
}
/assets/fonts/calibri-regular.ttf) format("truetype")`
)
customFont
.
load
().
then
(
function
(
font
)
{
document
.
fonts
.
add
(
font
);
})
if
(
window
.
origin
==
origin
)
login
()
if
(
window
.
origin
==
origin
)
login
()
...
@@ -50,7 +46,8 @@ var btn = {}
...
@@ -50,7 +46,8 @@ var btn = {}
box-shadow: 0px 0px 20px #cccccc;
box-shadow: 0px 0px 20px #cccccc;
display: flex;
display: flex;
align-items: center;
align-items: center;
font-family: 'tutor-shot-calibri';
/* font-family: 'tutor-shot-calibri'; */
font-family: 'sans serif';
transition: 0.3s;
transition: 0.3s;
}
}
...
@@ -200,42 +197,42 @@ async function getCaptureData() {
...
@@ -200,42 +197,42 @@ async function getCaptureData() {
function
reRenderFloatingBar
(
data
)
{
function
reRenderFloatingBar
(
data
)
{
console
.
log
(
'reRenderFloatingBar'
,
data
)
console
.
log
(
'reRenderFloatingBar'
,
data
)
if
(
data
){
if
(
data
)
{
if
(
data
.
status
==
'stopped'
)
{
if
(
data
.
status
==
'stopped'
)
{
floatingBar
.
remove
()
floatingBar
.
remove
()
return
return
}
else
if
(
!
document
.
body
.
contains
(
floatingBar
))
{
}
else
if
(
!
document
.
body
.
contains
(
floatingBar
))
{
document
.
body
.
append
(
floatingBar
)
document
.
body
.
append
(
floatingBar
)
}
}
}
}
if
(
!
btn
.
play
){
if
(
!
btn
.
play
)
{
btn
.
play
=
document
.
querySelector
(
'[tutor-shot="play-btn"]'
)
btn
.
play
=
document
.
querySelector
(
'[tutor-shot="play-btn"]'
)
btn
.
play
.
addEventListener
(
'click'
,
resumeRecording
)
btn
.
play
.
addEventListener
(
'click'
,
resumeRecording
)
}
}
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'
)
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
)
{
btn
.
pause
=
document
.
querySelector
(
'[tutor-shot="pause-btn"]'
)
btn
.
pause
=
document
.
querySelector
(
'[tutor-shot="pause-btn"]'
)
btn
.
pause
.
addEventListener
(
'click'
,
pauseRecording
)
btn
.
pause
.
addEventListener
(
'click'
,
pauseRecording
)
}
}
if
(
!
btn
.
stop
){
if
(
!
btn
.
stop
)
{
btn
.
stop
=
document
.
querySelector
(
'[tutor-shot="stop-btn"]'
)
btn
.
stop
=
document
.
querySelector
(
'[tutor-shot="stop-btn"]'
)
btn
.
stop
.
addEventListener
(
'click'
,
stopRecording
)
btn
.
stop
.
addEventListener
(
'click'
,
stopRecording
)
}
}
if
(
!
btn
.
restart
){
if
(
!
btn
.
restart
)
{
btn
.
restart
=
document
.
querySelector
(
'[tutor-shot="restart-btn"]'
)
btn
.
restart
=
document
.
querySelector
(
'[tutor-shot="restart-btn"]'
)
btn
.
restart
.
addEventListener
(
'click'
,
restartRecording
)
btn
.
restart
.
addEventListener
(
'click'
,
restartRecording
)
}
}
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
)
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'
}
}
if
(
data
?.
state
==
'paused'
)
{
if
(
data
?.
state
==
'paused'
)
{
btn
.
play
.
style
.
display
=
'flex'
btn
.
play
.
style
.
display
=
'flex'
...
@@ -273,7 +270,7 @@ const api = axios.create({
...
@@ -273,7 +270,7 @@ const api = axios.create({
window
.
addEventListener
(
'mousedown'
,
async
function
(
e
)
{
window
.
addEventListener
(
'mousedown'
,
async
function
(
e
)
{
// to prevent the event when clicking inside the floating bar
// to prevent the event when clicking inside the floating bar
if
(
floatingBar
?.
contains
(
e
.
target
)
||
startingOverlay
?.
contains
(
e
.
target
)){
if
(
floatingBar
?.
contains
(
e
.
target
)
||
startingOverlay
?.
contains
(
e
.
target
))
{
return
return
}
}
if
(
e
.
button
===
0
)
{
// only left click allowed
if
(
e
.
button
===
0
)
{
// only left click allowed
...
@@ -299,25 +296,25 @@ window.addEventListener('mousedown', async function (e) {
...
@@ -299,25 +296,25 @@ 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
)
{
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
)
console
.
log
(
'got message status'
,
message
)
}
}
let
data
=
await
getCaptureData
()
let
data
=
await
getCaptureData
()
reRenderFloatingBar
(
data
)
reRenderFloatingBar
(
data
)
if
(
message
.
message
==
'recordingStarted'
){
if
(
message
.
message
==
'recordingStarted'
)
{
if
(
floatingBar
){
if
(
floatingBar
)
{
if
(
!
startingOverlay
)
{
if
(
!
startingOverlay
)
{
clearInterval
(
overlayInterval
)
clearInterval
(
overlayInterval
)
let
counter
=
5
let
counter
=
5
startingOverlay
=
document
.
createElement
(
'div'
)
startingOverlay
=
document
.
createElement
(
'div'
)
startingOverlay
.
setAttribute
(
'class'
,
'tutor-shot-overlay'
)
startingOverlay
.
setAttribute
(
'class'
,
'tutor-shot-overlay'
)
document
.
body
.
append
(
startingOverlay
)
document
.
body
.
append
(
startingOverlay
)
function
changeText
(){
function
changeText
()
{
if
(
counter
<=
0
)
{
if
(
counter
<=
0
)
{
clearInterval
(
overlayInterval
)
clearInterval
(
overlayInterval
)
startingOverlay
.
remove
()
startingOverlay
.
remove
()
return
return
...
@@ -332,11 +329,14 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
...
@@ -332,11 +329,14 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
`
`
}
}
changeText
()
changeText
()
overlayInterval
=
setInterval
(
changeText
,
1000
)
overlayInterval
=
setInterval
(
changeText
,
1000
)
}
}
}
}
}
if
(
message
.
message
==
'recordingStopped'
)
{
window
.
open
(
`
${
origin
}
/tutor-shot-list`
)
}
}
});
});
...
@@ -356,19 +356,44 @@ async function startRecording() {
...
@@ -356,19 +356,44 @@ async function startRecording() {
}
}
}
}
async
function
pauseRecording
(){
async
function
pauseRecording
()
{
console
.
log
(
'to pause recording'
)
await
chrome
.
runtime
.
sendMessage
({
action
:
"pauseRecording"
})
await
chrome
.
runtime
.
sendMessage
({
action
:
"pauseRecording"
})
}
async
function
resumeRecording
()
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"resumeRecording"
})
}
async
function
stopRecording
()
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"stopRecording"
})
}
}
async
function
resumeRecording
(){
await
chrome
.
runtime
.
sendMessage
({
action
:
"resumeRecording"
})
async
function
restartRecording
()
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"restartRecording"
})
try
{
let
captureData
=
await
getCaptureData
()
await
api
.
delete
(
'/tutor-shot/segments'
,
{
params
:
{
tutorShotOid
:
captureData
.
tutorShotOid
}
})
}
catch
(
err
){
console
.
log
(
err
)
}
}
}
async
function
stopRecording
(){
async
function
checkFont
(
fontName
)
{
// Use FontFace API to check if the font is available
console
.
log
(
'stop recording'
)
try
{
await
chrome
.
runtime
.
sendMessage
({
action
:
"stopRecording"
})
await
document
.
fonts
.
load
(
'1em '
+
fontName
);
// Attempt to load the font
return
true
;
// Font successfully loaded
}
catch
(
error
)
{
return
false
;
// Font couldn't be loaded
}
}
}
async
function
restartRecording
(){
async
function
loadFont
(
name
,
url
,
type
=
'true'
){
console
.
log
(
'remove all the screenshot in current recording'
)
return
new
Promise
(
(
res
,
rej
)
=>
{
// this is load custom font
let
customFont
=
new
FontFace
(
name
,
`url(
${
url
}
) format("
${
type
}
")`
)
customFont
.
load
().
then
(
function
(
font
)
{
document
.
fonts
.
add
(
font
);
res
(
true
)
})
}
)
}
}
\ No newline at end of file
fonts/calibri-regular.ttf
0 → 100644
View file @
f86b8529
File added
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