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
f73b468d
Commit
f73b468d
authored
Dec 26, 2023
by
ramdayalmunda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refresh issue resolved
parent
9d806564
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
22 deletions
+53
-22
content.js
content.js
+50
-20
manifest.json
manifest.json
+2
-2
popup.js
popup.js
+1
-0
No files found.
content.js
View file @
f73b468d
...
...
@@ -9,10 +9,37 @@ const origin = "http://localhost:3039"
var
userDetails
=
{};
var
btn
=
{};
var
tutorShotOid
=
null
;
var
containerDiv
;
var
sr
;
!
(
async
function
()
{
if
(
window
.
origin
==
origin
)
login
()
containerDiv
=
document
.
createElement
(
'div'
)
containerDiv
.
style
.
position
=
"fixed"
containerDiv
.
style
.
display
=
"block"
containerDiv
.
style
.
background
=
"transparent"
containerDiv
.
style
.
width
=
"0px"
containerDiv
.
style
.
height
=
"0px"
containerDiv
.
style
.
zIndex
=
"9999"
document
.
body
.
append
(
containerDiv
)
const
observer
=
new
MutationObserver
(
async
function
(
mutationsList
,
observer
)
{
for
(
let
mutation
of
mutationsList
)
{
if
(
mutation
.
type
===
'childList'
&&
mutation
.
removedNodes
.
length
>
0
)
{
if
([...
mutation
.
removedNodes
].
includes
(
containerDiv
))
{
console
.
log
(
'The target node has been removed from the DOM.'
);
let
data
=
await
getCaptureData
()
reRenderFloatingBar
(
data
)
}
}
}
});
observer
.
observe
(
document
.
body
,
{
childList
:
true
})
sr
=
containerDiv
.
attachShadow
({
mode
:
'open'
});
let
styleTag
=
document
.
createElement
(
'style'
)
styleTag
.
setAttribute
(
'tutor-shot-style'
,
''
)
styleString
=
/*css*/
`
...
...
@@ -47,6 +74,7 @@ var tutorShotOid = null;
align-items: center;
font-family: Arial, Helvetica, sans-serif;
transition: 0.3s;
pointer-events: auto;
}
.tutor-shot.tutor-shot-right {
...
...
@@ -128,12 +156,11 @@ var tutorShotOid = null;
}
`
styleTag
.
innerHTML
=
styleString
document
.
body
.
append
(
styleTag
)
styleTag
.
append
(
styleString
)
sr
.
append
(
styleTag
)
floatingBar
=
document
.
createElement
(
'div'
)
floatingBar
.
setAttribute
(
'class'
,
`tutor-shot tutor-shot-right`
)
document
.
body
.
append
(
floatingBar
)
let
innerHTML
=
/*html*/
`
<div class="counter-count" tutor-shot="counter" style="display:none;"></div>
...
...
@@ -169,6 +196,8 @@ var tutorShotOid = null;
`
floatingBar
.
innerHTML
=
innerHTML
floatingBar
.
style
.
pointerEvents
=
'auto'
sr
.
append
(
floatingBar
)
floatingBar
.
addEventListener
(
'mouseenter'
,
(
e
)
=>
{
floatingBar
.
style
.
width
=
''
...
...
@@ -180,6 +209,7 @@ var tutorShotOid = null;
document
.
addEventListener
(
"visibilitychange"
,
async
function
()
{
if
(
document
.
visibilityState
===
'visible'
)
{
if
(
window
.
origin
==
origin
)
login
()
let
data
=
await
getCaptureData
()
reRenderFloatingBar
(
data
)
}
...
...
@@ -210,44 +240,44 @@ async function getCaptureData() {
function
reRenderFloatingBar
(
data
)
{
if
(
data
)
{
if
(
data
.
status
==
'stopped'
)
{
floatingBar
.
remove
()
containerDiv
.
remove
()
return
}
else
if
(
!
document
.
body
.
contains
(
floatingBar
))
{
document
.
body
.
append
(
floatingBar
)
document
.
body
.
append
(
containerDiv
)
}
}
if
(
!
btn
.
play
)
{
btn
.
play
=
document
.
querySelector
(
'[tutor-shot="play-btn"]'
)
btn
.
play
=
sr
.
querySelector
(
'[tutor-shot="play-btn"]'
)
btn
.
play
.
addEventListener
(
'click'
,
resumeRecording
)
}
if
(
!
btn
.
mainLogo
){
btn
.
mainLogo
=
document
.
querySelector
(
'[tutor-shot="main-logo"]'
)
if
(
!
btn
.
mainLogo
)
{
btn
.
mainLogo
=
sr
.
querySelector
(
'[tutor-shot="main-logo"]'
)
}
if
(
!
btn
.
generatingVideo
){
btn
.
generatingVideo
=
document
.
querySelector
(
'[tutor-shot="generating-video"]'
)
if
(
!
btn
.
generatingVideo
)
{
btn
.
generatingVideo
=
sr
.
querySelector
(
'[tutor-shot="generating-video"]'
)
}
if
(
!
btn
.
capture
)
{
btn
.
capture
=
document
.
querySelector
(
'[tutor-shot="capture-btn"]'
)
btn
.
capture
=
sr
.
querySelector
(
'[tutor-shot="capture-btn"]'
)
}
if
(
!
btn
.
playText
)
btn
.
playText
=
document
.
querySelector
(
'[tutor-shot="play-text"]'
)
if
(
!
btn
.
playText
)
btn
.
playText
=
sr
.
querySelector
(
'[tutor-shot="play-text"]'
)
if
(
!
btn
.
pause
)
{
btn
.
pause
=
document
.
querySelector
(
'[tutor-shot="pause-btn"]'
)
btn
.
pause
=
sr
.
querySelector
(
'[tutor-shot="pause-btn"]'
)
btn
.
pause
.
addEventListener
(
'click'
,
pauseRecording
)
}
if
(
!
btn
.
stop
)
{
btn
.
stop
=
document
.
querySelector
(
'[tutor-shot="stop-btn"]'
)
btn
.
stop
=
sr
.
querySelector
(
'[tutor-shot="stop-btn"]'
)
btn
.
stop
.
addEventListener
(
'click'
,
stopRecording
)
}
if
(
!
btn
.
restart
)
{
btn
.
restart
=
document
.
querySelector
(
'[tutor-shot="restart-btn"]'
)
btn
.
restart
=
sr
.
querySelector
(
'[tutor-shot="restart-btn"]'
)
btn
.
restart
.
addEventListener
(
'click'
,
restartRecording
)
}
if
(
!
btn
.
switch
)
{
btn
.
switch
=
document
.
querySelector
(
'[tutor-shot="switch-btn"]'
)
btn
.
switch
=
sr
.
querySelector
(
'[tutor-shot="switch-btn"]'
)
btn
.
switch
.
addEventListener
(
'click'
,
changeBarPosition
)
}
if
(
!
btn
.
counter
)
btn
.
counter
=
document
.
querySelector
(
'[tutor-shot="counter"]'
)
if
(
!
btn
.
counter
)
btn
.
counter
=
sr
.
querySelector
(
'[tutor-shot="counter"]'
)
if
(
data
?.
hasOwnProperty
(
'imageNumber'
))
{
btn
.
counter
.
innerHTML
=
`
${
data
.
imageNumber
}
`
...
...
@@ -271,7 +301,7 @@ function reRenderFloatingBar(data) {
btn
.
mainLogo
.
style
.
display
=
'block'
// btn.capture.style.display = 'flex'
}
else
if
(
data
?.
status
==
'generatingVideo'
)
{
else
if
(
data
?.
status
==
'generatingVideo'
)
{
btn
.
play
.
style
.
display
=
'none'
btn
.
pause
.
style
.
display
=
'none'
btn
.
stop
.
style
.
display
=
'none'
...
...
@@ -301,7 +331,7 @@ const api = axios.create({
window
.
addEventListener
(
'mousedown'
,
async
function
(
e
)
{
// to prevent the event when clicking inside the floating bar
if
(
floatingBar
?.
contains
(
e
.
target
)
||
startingOverlay
?.
contains
(
e
.
target
))
{
if
(
containerDiv
?.
contains
(
e
.
target
)
||
startingOverlay
?.
contains
(
e
.
target
))
{
return
}
if
(
e
.
button
===
0
)
{
// only left click allowed
...
...
@@ -341,7 +371,7 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
let
counter
=
5
startingOverlay
=
document
.
createElement
(
'div'
)
startingOverlay
.
setAttribute
(
'class'
,
'tutor-shot-overlay'
)
document
.
body
.
append
(
startingOverlay
)
sr
.
append
(
startingOverlay
)
function
changeText
()
{
if
(
counter
<=
0
)
{
clearInterval
(
overlayInterval
)
...
...
manifest.json
View file @
f73b468d
{
"manifest_version"
:
3
,
"name"
:
"Tutor Shot"
,
"version"
:
"1.
0
"
,
"name"
:
"Tutor Shot
Local
"
,
"version"
:
"1.
2
"
,
"description"
:
"Capture web-page screenshots instantly with a single click. They're saved to your account at http://localhost:3039."
,
"permissions"
:
[
"activeTab"
,
...
...
popup.js
View file @
f73b468d
...
...
@@ -96,6 +96,7 @@
}
// this code should run everytime the popup is opened
document
.
addEventListener
(
"DOMContentLoaded"
,
domLoadHandler
);
console
.
log
(
'pop-up loaded again'
)
...
...
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