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
506b1999
Commit
506b1999
authored
May 17, 2024
by
Pragati Upadhyay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set limit of video according to pricing plan
parent
6c571046
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
3 deletions
+65
-3
background.js
background.js
+5
-0
content.js
content.js
+20
-2
popup.js
popup.js
+40
-1
No files found.
background.js
View file @
506b1999
...
...
@@ -289,6 +289,10 @@ var getUserDetails = null
return
}
}
if
(
loggedIn
&&
request
.
action
===
'limitExceed'
)
{
sendMessageToActiveTab
(
"limitExceed"
)
return
}
if
(
request
.
action
===
'logout'
)
{
loggedIn
=
false
;
recording
=
false
;
...
...
@@ -335,6 +339,7 @@ var getUserDetails = null
}
chrome
.
tabs
.
query
({
active
:
true
,
currentWindow
:
true
},
function
(
tabs
)
{
if
(
tabs
&&
tabs
.
length
)
{
// if any tab is active
console
.
log
(
"🚀 ~ tabs:"
,
tabs
)
var
activeTab
=
tabs
[
0
]
chrome
.
tabs
.
captureVisibleTab
({
format
:
"png"
},
async
function
(
dataUrl
)
{
let
message
=
{
...
...
content.js
View file @
506b1999
...
...
@@ -223,7 +223,8 @@ async function login() {
let
userDetails
=
{
uid
:
localStorage
.
getItem
(
'userId'
),
name
:
localStorage
.
getItem
(
'name'
),
email
:
localStorage
.
getItem
(
'email'
)
email
:
localStorage
.
getItem
(
'email'
),
userOid
:
localStorage
.
getItem
(
'userOid'
)
}
if
(
userDetails
?.
uid
||
userDetails
?.
email
)
{
// can login
chrome
.
runtime
.
sendMessage
({
action
:
"login"
,
userDetails
})
...
...
@@ -388,7 +389,7 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
document
.
body
.
append
(
finalizingOverlay
)
finalizingOverlay
.
innerHTML
=
`
<div>
No
Image found
.
No
screenshots have been captured for video creation yet
.
</div>
`
setTimeout
(()
=>
{
...
...
@@ -402,6 +403,23 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
},
2000
)
reRenderFloatingBar
(
data
)
}
else
if
(
message
.
message
==
'limitExceed'
)
{
finalizingOverlay
=
document
.
createElement
(
'div'
)
finalizingOverlay
.
setAttribute
(
'class'
,
'tutor-shot-overlay'
)
finalizingOverlay
.
setAttribute
(
'style'
,
`all: unset; position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; background-color: #000000a0; pointer-events: inherit; z-index: 101; display: flex; color: white; justify-content: center; align-items: center; font-size: 28px;`
)
document
.
body
.
append
(
finalizingOverlay
)
finalizingOverlay
.
innerHTML
=
`
<div>
Video creation limit reached.
Upgrade to continue or contact support.
</div>
`
setTimeout
(()
=>
{
finalizingOverlay
.
remove
()
reRenderFloatingBar
(
data
)
},
2000
)
reRenderFloatingBar
(
data
)
}
else
if
(
message
.
message
==
'generatingVideo'
)
{
finalizingOverlay
=
document
.
createElement
(
'div'
)
finalizingOverlay
.
setAttribute
(
'class'
,
'tutor-shot-overlay'
)
...
...
popup.js
View file @
506b1999
...
...
@@ -22,6 +22,9 @@
let
logoutBtn
=
document
.
getElementById
(
'logout-btn'
)
myCapturesBtn
.
addEventListener
(
'click'
,(
e
)
=>
{
window
.
open
(
origin
+
'/tutor-shot-list'
)
})
let
userDetails
=
{};
let
maxTutorShotLimit
=
{};
let
savedTutorShot
=
{};
let
inProgress
=
false
;
logoutBtn
.
addEventListener
(
'click'
,
()
=>
{
...
...
@@ -42,6 +45,17 @@
}
inProgress
=
true
try
{
let
limitExceed
=
await
getSubscriptions
()
if
(
limitExceed
){
window
.
close
()
chrome
.
runtime
.
sendMessage
({
action
:
"limitExceed"
},
async
function
(
response
)
{
loggedIn
=
false
userDetails
.
email
=
""
userDetails
.
uid
=
""
modifyPopupUI
()
})
return
;
}
let
{
data
}
=
await
api
.
post
(
'/tutor-shot'
,
{
title
:
"No Title"
},
{
headers
:
{
userId
:
userDetails
.
uid
}
}
)
if
(
data
.
success
){
chrome
.
runtime
.
sendMessage
({
action
:
"startRecording"
,
tutorShotId
:
data
.
tutorShot
.
_id
},
async
function
(
response
)
{
...
...
@@ -85,7 +99,32 @@
}
}
let
getAuthHeader
=
function
(){
return
{
headers
:
{
username
:
userDetails
.
name
,
userid
:
userDetails
.
uid
,
useroid
:
userDetails
.
userOid
,
}
}
}
async
function
getSubscriptions
(){
try
{
if
(
!
userDetails
.
uid
)
return
let
{
data
}
=
await
api
.
get
(
"common/subscriptions"
,
{
headers
:
getAuthHeader
().
headers
})
if
(
data
.
success
){
const
moduleObject
=
data
.
subscriptionData
.
feature
.
find
(
obj
=>
obj
.
module
===
'TUTOR_SHOT'
);
maxTutorShotLimit
=
moduleObject
?
moduleObject
.
quantity
:
null
;
api
.
defaults
.
headers
.
userId
=
userDetails
.
uid
const
tutorData
=
await
api
.
get
(
"tutor-shot/"
)
savedTutorShot
=
tutorData
.
data
.
list
.
length
if
(
maxTutorShotLimit
<=
savedTutorShot
)
return
true
else
return
false
}
}
catch
(
err
){
console
.
log
(
err
)
}
}
function
domLoadHandler
()
{
chrome
.
runtime
.
sendMessage
({
action
:
"checkStatus"
},
function
(
response
)
{
...
...
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