Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
html2pdf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Lukas Niegsch
html2pdf
Commits
839d73b0
Commit
839d73b0
authored
Jun 11, 2022
by
lukas.niegsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created connection to headless chromium
parent
64e6dd7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
2 deletions
+40
-2
chromium.js
chromium.js
+24
-0
index.html
index.html
+16
-2
No files found.
chromium.js
View file @
839d73b0
class
HeadlessChromium
{
constructor
(
websocketUrl
)
{
this
.
websocketUrl
=
websocketUrl
this
.
websocket
=
new
WebSocket
(
websocketUrl
)
}
isConnected
()
{
return
this
.
websocket
.
readyState
==
WebSocket
.
OPEN
}
runCommand
(
method
,
params
=
{},
callback
)
{
var
command
=
{
id
:
0
,
method
:
method
,
params
:
params
}
this
.
websocket
.
send
(
JSON
.
stringify
(
command
))
this
.
websocket
.
onmessage
=
(
response
)
=>
{
callback
(
response
.
data
)
}
}
}
index.html
View file @
839d73b0
...
...
@@ -7,10 +7,24 @@
<script
src=
"connection.js"
></script>
<script
src=
"chromium.js"
></script>
<script>
var
searchParams
=
(
new
URL
(
window
.
location
.
href
)).
searchParams
var
websocketUrl
=
searchParams
.
get
(
"
websocket
"
)
var
browser
=
new
HeadlessChromium
(
websocketUrl
)
function
mainloop
()
{
console
.
log
(
"
Hello, World
"
+
test
())
setTimeout
(
mainloop
,
5
/* seconds */
*
1000
)
if
(
browser
.
isConnected
())
{
browser
.
runCommand
(
"
Browser.getVersion
"
,
{},
(
version
)
=>
{
console
.
log
(
version
)
})
}
else
{
console
.
log
(
"
Not connected!
"
)
}
setTimeout
(
mainloop
,
2
/* seconds */
*
1000
)
}
mainloop
()
</script>
...
...
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