-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48c0865
commit 31ce357
Showing
7 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
yolov8m-seg.pt | ||
downloaded_files/* | ||
.idea/* | ||
*/__pycache__/* | ||
*/__pycache__/* | ||
node_modules/* | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "module", | ||
"dependencies": { | ||
"puppeteer": "^23.4.0", | ||
"static-server": "^3.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import puppeteer from 'puppeteer'; | ||
import {__server_url__, sleep} from './utils.js' | ||
|
||
const script = async ()=>{ | ||
await brotector.init_done | ||
return brotector.detections | ||
} | ||
|
||
const browser = await puppeteer.launch({ headless: false }); | ||
try{ | ||
const page = await browser.newPage(); | ||
|
||
// Navigate the page to a URL. | ||
await page.goto(__server_url__); | ||
await sleep(500) | ||
await page.click("#clickHere") | ||
const detections = await page.evaluate(script) | ||
if(detections.length == 0){throw Error("Not detected")} | ||
console.log(detections) | ||
}finally{ | ||
await browser.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { dirname } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import net from "net"; | ||
import StaticServer from 'static-server' | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
const __main_dir__ = dirname(__dirname) | ||
|
||
function sleep (time) { | ||
return new Promise((resolve) => setTimeout(resolve, time)); | ||
} | ||
|
||
const port = await new Promise( res => { | ||
const srv = net.createServer(); | ||
srv.listen(0, () => { | ||
const port = srv.address().port | ||
srv.close((err) => res(port)) | ||
}); | ||
}) | ||
|
||
const __server_url__ = `http://localhost:${port}` | ||
|
||
const server = new StaticServer({ | ||
rootPath: __main_dir__, // required, the root of the server file tree | ||
port: port, // required, the port to listen | ||
host: 'localhost', // optional, defaults to any interface | ||
}); | ||
|
||
await new Promise((resolve, reject)=>{ | ||
try{ | ||
server.start(resolve) | ||
}catch(e){reject(e)} | ||
}) | ||
|
||
export { __main_dir__, __server_url__, sleep} |