diff --git a/.gitignore b/.gitignore index 4d29575..2e4a1ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea/ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies diff --git a/package.json b/package.json index 0c13926..f6a3650 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "scripts": { "start": "react-scripts start", "build": "react-scripts build", + "watch": "react-scripts build - -watch", "test": "react-scripts test", "eject": "react-scripts eject" }, diff --git a/public/background.js b/public/background.js new file mode 100644 index 0000000..d57c301 --- /dev/null +++ b/public/background.js @@ -0,0 +1,54 @@ +let socket; +const connectWebsocket = url => { + disconnectWebsocket() + socket = new WebSocket(url); + socket.onopen = () => { + chrome.runtime.sendMessage({status: "connected"}) + } + socket.onclose = () => { + chrome.runtime.sendMessage({status: "disconnected"}) + } +} + +const disconnectWebsocket = () => { + if (socket) { + try { + socket.close() + socket = null; + } catch (e) { + + } + } +} + +heartbeat = () => { + if (socket) { + if (socket.readyState === WebSocket.OPEN) { + try { + socket.send(JSON.stringify({ + "type": "heartbeat", + })) + } catch (e) { + console.error("Error sending heartbeat:", e); + } + } else { + disconnectWebsocket() + } + } +} +heartbeat() +setInterval(heartbeat, 3000) + +console.info("Chrome Extenstion Background is loaded") +chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { + if (msg.action === "connectWebsocket") { + console.info("Start to connect websocket") + connectWebsocket(msg.url) + } else if (msg.action === "init") { + if (socket) { + chrome.runtime.sendMessage({status: "connected"}) + } else { + chrome.runtime.sendMessage({status: "initialized"}) + } + } +}) diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index a11777c..0000000 Binary files a/public/favicon.ico and /dev/null differ diff --git a/public/images/icon128.png b/public/images/icon128.png new file mode 100644 index 0000000..7df3a1c Binary files /dev/null and b/public/images/icon128.png differ diff --git a/public/images/icon16.png b/public/images/icon16.png new file mode 100644 index 0000000..a6ef813 Binary files /dev/null and b/public/images/icon16.png differ diff --git a/public/images/icon48.png b/public/images/icon48.png new file mode 100644 index 0000000..b59b6e6 Binary files /dev/null and b/public/images/icon48.png differ diff --git a/public/images/yakitlogo.png b/public/images/yakitlogo.png new file mode 100644 index 0000000..a2fa6f9 Binary files /dev/null and b/public/images/yakitlogo.png differ diff --git a/public/index.html b/public/index.html index aa069f2..8408e7a 100644 --- a/public/index.html +++ b/public/index.html @@ -1,43 +1,13 @@ - - - - - - - - - - + + + + React App - - - -
- - + + + +
+ diff --git a/public/logo192.png b/public/logo192.png deleted file mode 100644 index fc44b0a..0000000 Binary files a/public/logo192.png and /dev/null differ diff --git a/public/logo512.png b/public/logo512.png deleted file mode 100644 index a4e47a6..0000000 Binary files a/public/logo512.png and /dev/null differ diff --git a/public/manifest.json b/public/manifest.json index 080d6c7..c6d7a8a 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,25 +1,40 @@ { - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ + "manifest_version": 3, + "name": "Yakit Chrome Endpoint", + "version": "1.0", + "description": "A Endpoint for Yakit MITM or more", + "action": { + "default_popup": "popup.html", + "default_icon": { + "16": "/images/icon16.png", + "48": "/images/icon48.png", + "128": "/images/icon128.png" + } + }, + "background": { + "service_worker": "background.js" + }, + "permissions": [ + "activeTab", + "scripting", + "tabs", + "proxy", + "storage", + "webRequest" + ], + "content_scripts": [ { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" + "matches": [ + "" + ], + "js": [ + "content.js" + ] } ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} + "icons": { + "16": "/images/icon16.png", + "48": "/images/icon48.png", + "128": "/images/icon128.png" + } +} \ No newline at end of file diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100644 index e9e57dc..0000000 --- a/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/src/App.js b/src/App.js index 3784575..5ad942d 100644 --- a/src/App.js +++ b/src/App.js @@ -2,24 +2,11 @@ import logo from './logo.svg'; import './App.css'; function App() { - return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
-
- ); + return ( +
+ Hello Ext from react! +
+ ); } export default App;