diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1eec882..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -sampleTest -web-ext-artifacts \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b969529..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "markdown.preview.fontSize": 13, - "[markdown]": { - "editor.fontSize": 14, - "editor.wordWrap": "off", - "files.trimTrailingWhitespace": false, - "editor.minimap.enabled": false - }, - // "liveServer.settings.proxy": { - // "enable": true, - // "baseUri": "/", - // "proxyUri": "http://127.0.0.1:80" - // } -} diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 47fc68e..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "taskName": "Build", - "type": "shell", - "command": "web-ext build -o -i=\"img/screenshots/**\" \"sampleTest/**\" && echo Done!" - } - ] -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index b18d887..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Changelog -| Version | Date | Changelog | -|---|---|---| -| 2.0.0|25.12.24| manifest.json v3 upgrade [#129](https://github.com/ritwickdey/live-server-web-extension/pull/129) -| 1.3.0|18.05.18| — ***[Fixed]*** Reload all browser tabs [[#16](https://github.com/ritwickdey/live-server-web-extension/issues/16)] | -| 1.2.0|17.05.18| — Serious Bug Fixe | -| 1.1.0|17.05.18| — This extension was broken with Live Server v4.0.0 update. [[#127](https://github.com/ritwickdey/vscode-live-server/issues/127)]
— Popup window UI updated
— Docs updated. | -| 1.0.0 | 26.10.17 | — ***[New Feature]*** No need to setup proxy. There is now a way to setup - that is pretty easy & straight-forward.

— ***[Enhancement]*** Pop-up window is redesigned.

— ***[Bug Fixes]*** Small bug fixes related to the turn on/off switch.

— No BETA. General Release. | -0.0.1 | 22.10.17 | Initial Release under BETA | diff --git a/LICENSE b/LICENSE deleted file mode 100644 index cfc20f4..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Ritwick Dey - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 4d60a31..0000000 --- a/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Live Server - Web Extension -Makes your existing server live - -[![Chrome Web Store](https://img.shields.io/chrome-web-store/v/fiegdmejfepffgpnejdinekhfieaogmj.svg?style=for-the-badge)](https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj)[![Chrome Web Store](https://img.shields.io/chrome-web-store/users/fiegdmejfepffgpnejdinekhfieaogmj.svg?style=for-the-badge)](https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj)[![Chrome Web Store](https://img.shields.io/chrome-web-store/rating/fiegdmejfepffgpnejdinekhfieaogmj.svg?style=for-the-badge)](https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj/reviews) -[![Mozilla Add-on](https://img.shields.io/amo/v/live-server-web-extension.svg?style=for-the-badge)](https://addons.mozilla.org/en-US/firefox/addon/live-server-web-extension/)[![Mozilla Add-on](https://img.shields.io/amo/users/live-server-web-extension.svg?style=for-the-badge)](https://addons.mozilla.org/en-US/firefox/addon/live-server-web-extension/)[![Mozilla Add-on](https://img.shields.io/amo/rating/live-server-web-extension.svg?style=for-the-badge)](https://addons.mozilla.org/en-US/firefox/addon/live-server-web-extension/reviews/) - -### Brief Description -This browser add-on is an extension for a developer tool in VS Code editor ([Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer)). With this add-on installed, along with the VS Code extension, it gives you a functionality to automatically update your website on save; for other files than just `.htm` and `.html`. - -So specifically, with this add-on, live reload will also work with the following server-side files within the spectrum of: `PHP`, `.NET` and `NodeJS`. - -

- -### Privacy Policy -This extension does not collect or store any user data. As simple as it is! :) - -

- -### Documentation -***[Setup Tutorial](./docs/Setup.md)*** -***[About The Extension](./docs/About.md)*** -***[FAQ](./docs/FAQ.md)*** -
- -#### The Common Misconception -Neither the browser add-on nor the VS Code extension will host a server for: `PHP`, `.NET` or `NodeJS`. This add-on will give you the *reloading function*, so you do not need to refresh the page every time you save your server-side code. - -

- - -### Store Links - -* Chrome : https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj -* Firefox : https://addons.mozilla.org/en-US/firefox/addon/live-server-web-extension/ - -

- -### News - -* #### Verision 1.3.0 (18.05.18) - * ***[Fixed]*** Reload all browser tabs [[#16](https://github.com/ritwickdey/live-server-web-extension/issues/16)] - - -* #### Verision 1.2.0 (17.05.18) - * Serious Bug Fixed - -* #### Verision 1.1.0 (17.05.18) - * ***[Bug Fixed]*** This extension was broken with Live Server v4.0.0 update. [[#127](https://github.com/ritwickdey/vscode-live-server/issues/127)] - * Popup window UI updated - * Docs updated. - -

- - -### License -This extension is licensed under the [MIT License](./LICENSE) diff --git a/background.js b/background.js deleted file mode 100644 index 3822145..0000000 --- a/background.js +++ /dev/null @@ -1,51 +0,0 @@ -; (function () { - - 'use strict'; - - const SETUP_STRING = 'live-reload-extension-new-setup-v2'; - - function sendMsgToAllContainPage(req, data) { - chrome.tabs.query({}, tabs => { - tabs.forEach(tab => { - chrome.tabs.sendMessage(tab.id, { - req: req, - data: data - }); - }); - }); - } - - function storeConfigToLocalStorage(data) { - // return promise - return chrome.storage.local.set({ [SETUP_STRING]: data || {} }) - } - - function getConfigFromLocalStorage() { - return new Promise((resolve) => { - chrome.storage.local.get([SETUP_STRING], (result) => { - resolve(result[SETUP_STRING] || {}); - }); - }); - } - - chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { - - if (typeof msg !== 'object') return; - if (msg.req === 'set-live-server-config') { - storeConfigToLocalStorage(msg.data); - sendMsgToAllContainPage('live-server-config-updated', msg.data); - } - else if (msg.req === 'get-live-server-config') { - getConfigFromLocalStorage() - .then(function (value) { - sendResponse(value) - }) - .catch(function (error) { - console.error("Error in get-live-server-config:",error); - sendResponse({}) - }); - } - return true; //Keep the callback(sendResponse) active - }); - -})(); \ No newline at end of file diff --git a/docs/About.md b/docs/About.md deleted file mode 100644 index e092710..0000000 --- a/docs/About.md +++ /dev/null @@ -1,51 +0,0 @@ -# About - -### That's why I built this extension. -The reason I built this browser add-on is to delight the experience of server-side programming. -Many of you have probably experienced the frustration when you work with server side code and -that you have to manually update the webpage every time you save the document. - -Therefore, I've chosen to build an additional add-on to an already existing vscode extension, -thus providing the option of live reload when working with a particular framework or server. - -
- -![Illustration GIF-image](./../img/screenshots/live-server-web-extension.gif) - -

- -# Code Insight -```js -master/ -┃ -┣━━img/ // Folder with images -┃ -┣━━popup/ // Folder for the popup page -┃ -┣━━manifest.json // Initiate the extension to app store -┣━━background.js // Background script -┗━━reload.js // Reload functionality -``` -
- -#### manifest.json -The manifest.json file is a JSON-formatted file, and is the only file that every extension using WebExtension APIs must contain. - -Using manifest.json, you specify basic metadata about your extension such as the name and version - -[Read more...](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json) - -
- -#### background.js -Background scripts are the place to put code that needs to maintain long-term state, or perform long-term operations, independently of the lifetime of any particular web pages or browser windows. - -Background scripts are loaded as soon as the extension is loaded and stay loaded until the extension is disabled or uninstalled. You can use any of the WebExtension APIs in the script, as long as you have requested the necessary permissions. - -[Read more...](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/background) - -
- -#### reload.js -info is needed... -*[all through you can use the npm package [live-server](https://www.npmjs.com/package/live-server)]* diff --git a/docs/FAQ.md b/docs/FAQ.md deleted file mode 100644 index 471c3f1..0000000 --- a/docs/FAQ.md +++ /dev/null @@ -1,37 +0,0 @@ -# Frequently Asked Questions - -
- -### PHP will download instead of executing -I'm new to this live-server thing. I have used it for *`.html`* pages, and it worked flawlessly! But now, when I want to use it for php pages, it downloads the .php file instead of executing it. - -**Answer:** -1. [The Common Misconception](#the-common-misconception) -2. You will need to install a server on your machine or download the necessary requirements. Here is a Stackoverflow question: [PHP server on local machine?](https://stackoverflow.com/questions/1678010/php-server-on-local-machine) - + [PHP](http://php.net/downloads.php) (just the preprocessor without apache) - + [XAMPP](https://www.apachefriends.org/index.html) (cross-platform) - + [MAMP](https://www.mamp.info/en/downloads/) (mac) - + [WAMP](http://www.wampserver.com/en/) (windows) -3. Visit the ***Actual Server Address***: `http://localhost/[workspace]`, not the VS Code extension's ***Live Server Address***: `http://127.0.0.1:5500/` - -



- -### Why do I have to run a separate server -Hi, I wonder why I have to run my own server when the vscode extension will start one at: `http://127.0.0.1:5500/`, when I go live? - -**Answer:** -The two main reasons are the flexibility, and the complexity of server-side environment. -For instance, in order to be able to use this add-on in all environments and not to -prevent the user from a specific php verion, or running Apache with PHP. -It is therefore preferable that you as a user can decide for yourself which environment to use. -Another thing is that the server side is heavier than the client side because it needs a -larger server environment to run- and preprocess your code in PHP, NodeJS or .NET. - -


->## The Common Misconception ->Neither the browser add-on nor the VS Code extension will host a server for: `PHP`, `.NET` or `NodeJS`. -This add-on will give you the *reloading function*, so you do not need to refresh the webpage every time you save. -> ->The reason I built this browser add-on is to delight the experience of server-side programming. -The server-side is heavier than the client-side because it needs a larger server environment to -run and preprocess your code in: `PHP`, `NodeJS` or `.NET`. diff --git a/docs/Setup.md b/docs/Setup.md deleted file mode 100644 index 54a17de..0000000 --- a/docs/Setup.md +++ /dev/null @@ -1,80 +0,0 @@ -# Setup -#### The Common Misconception -Neither the browser add-on nor the VS Code extension will host a server for: `PHP`, `.NET` or `NodeJS`. It will give you the *reloading function*, so you do not need to refresh the page every time you save. - -In other words. If you just want the reload feature when working with .html files, then you do not need this add-on at all. - -
- -***Need Help? [Watch Video Tutorial](https://www.youtube.com/watch?v=54wcX1G2GH8)*** - -

- -# Direct Setup`Easy` || Proxy Setup`Advanced` - -### Direct Setup - -1. Install [VS Code](https://code.visualstudio.com/download) from Microsoft. (code editor) -2. Install VS Code [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). (extension to code editor) -3. Install the browser add-on; [Chrome](https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj/) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/live-server-web-extension/). -4. Install and run a server on your machine: [Servers and Frameworks](#servers-and-frameworks) -5. Place your app on the server you want to use and open your project there. -6. Enter the neccesary fields (screenshot below) - 1. **Actual Server Address:** is the address where your server is located and the port. - 2. **Live Server Address:** is the address where your VS code extension is running. -7. Push the `Go Live`-button in your editor's statusbar. -8. Visit the `Actual Server Address` - -![two-step-image](./../img/screenshots/direct-setup.png) - -

- -### Proxy Setup -1. Install [VS Code](https://code.visualstudio.com/download) from Microsoft. (code editor) -2. Install VS Code [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). (extension to code editor) -3. Install the browser add-on; [Chrome](https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj/) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/live-server-web-extension/). -4. Install and run a server on your machine: [Servers and Frameworks](#servers-and-frameworks) -5. Place your app on the server you want to use and open your project there. -6. Enter the neccesary values (code block below) - 1. **enable:** whether it is enabled or not. - 2. **baseUri:** is the path to the folder you want proxy from. The path is relative to the workspace. - 3. **proxyUri:** is the address where your server (xampp or similar server) is located, and the port. -7. Push the `Go Live`-button in your editor's statusbar. - -*`.vscode/settings.json`* -```js -{ - // Mainly for static files - "liveServer.settings.useWebExt": true, - - // This means that you change your real URL (current PHP url) - // to another URL (which Live Sever starts). - "liveServer.settings.proxy": { - "enable": true, // i. enabled - "baseUri": "/", // ii. workspace - "proxyUri": "http://localhost:80/workspace" // iii. actual address - }, -} - -``` ->**Note:** You need to stay on the new host that will be provided by Live Server. - -


- -# Servers and Frameworks - - -### PHP -+ [PHP](http://php.net/downloads.php) `just the preprocessor` -+ [XAMPP](https://www.apachefriends.org/index.html) `cross-platform` -+ [MAMP](https://www.mamp.info/en/downloads/) `mac` -+ [WAMP](http://www.wampserver.com/en/) `windows` - - -### NodeJS -+ [ExpressJS](https://expressjs.com/en/starter/installing.html) `cross-platform` - - -### .Net -+ [DotNet Core](https://www.microsoft.com/net/learn/get-started/windows) `cross-platform` -+ [IIS](https://www.iis.net/) `windows` diff --git a/img/icon.png b/img/icon.png deleted file mode 100644 index 4cc69f8..0000000 Binary files a/img/icon.png and /dev/null differ diff --git a/img/icon128.png b/img/icon128.png deleted file mode 100644 index 3f8409d..0000000 Binary files a/img/icon128.png and /dev/null differ diff --git a/img/screenshots/direct-setup.png b/img/screenshots/direct-setup.png deleted file mode 100644 index acb59b3..0000000 Binary files a/img/screenshots/direct-setup.png and /dev/null differ diff --git a/img/screenshots/live-server-web-extension-easy-setup.png b/img/screenshots/live-server-web-extension-easy-setup.png deleted file mode 100644 index fc31520..0000000 Binary files a/img/screenshots/live-server-web-extension-easy-setup.png and /dev/null differ diff --git a/img/screenshots/live-server-web-extension.gif b/img/screenshots/live-server-web-extension.gif deleted file mode 100644 index e82a394..0000000 Binary files a/img/screenshots/live-server-web-extension.gif and /dev/null differ diff --git a/makefile b/makefile deleted file mode 100644 index 934308c..0000000 --- a/makefile +++ /dev/null @@ -1,2 +0,0 @@ -package: - web-ext build -o -i="img/screenshots/**" "sampleTest/**" && echo Done! \ No newline at end of file diff --git a/manifest.json b/manifest.json deleted file mode 100644 index e04afcf..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "manifest_version": 3, - "name": "Live Server Web Extension", - "version": "2.0.0", - "description": "Makes your existing server live. This is a browser extension that helps you to live reload feature for dynamic pages", - "icons": { - "96": "./img/icon.png", - "128": "./img/icon128.png" - }, - "author": "Ritwick Dey", - "short_name": "Live Server Web Extension", - "homepage_url": "https://github.com/ritwickdey/live-server-web-extension", - "content_scripts": [ - { - "matches": [ - "http://*/*", - "https://*/*" - ], - "js": [ - "reload.js" - ] - } - ], - "background": { - "service_worker": "background.js", - "type": "module" - }, - "action": { - "default_popup": "./popup/popup.html", - "default_icon": "./img/icon.png", - "default_title": "Live Server" - }, - "permissions": [ - "storage" - ], - "host_permissions": [ - "http://*/*", - "https://*/*" - ] -} \ No newline at end of file diff --git a/popup/css/button.css b/popup/css/button.css deleted file mode 100644 index 70b7559..0000000 --- a/popup/css/button.css +++ /dev/null @@ -1,108 +0,0 @@ -/* -this awesome button css taken from Codepen.io -https://codepen.io/mallendeo/pen/eLIiG -*/ - -.tgl { - display: none; -} - -.tgl, -.tgl:after, -.tgl:before, -.tgl *, -.tgl *:after, -.tgl *:before, -.tgl+.tgl-btn { - box-sizing: border-box; -} - -.tgl::-moz-selection, -.tgl:after::-moz-selection, -.tgl:before::-moz-selection, -.tgl *::-moz-selection, -.tgl *:after::-moz-selection, -.tgl *:before::-moz-selection, -.tgl+.tgl-btn::-moz-selection { - background: none; -} - -.tgl::selection, -.tgl:after::selection, -.tgl:before::selection, -.tgl *::selection, -.tgl *:after::selection, -.tgl *:before::selection, -.tgl+.tgl-btn::selection { - background: none; -} - -.tgl+.tgl-btn { - outline: 0; - display: block; - width: 4em; - height: 2em; - position: relative; - cursor: pointer; - user-select: none; -} - -.tgl+.tgl-btn:after, -.tgl+.tgl-btn:before { - position: relative; - display: block; - content: ""; - width: 50%; - height: 100%; -} - -.tgl+.tgl-btn:after { - left: 0; -} - -.tgl+.tgl-btn:before { - display: none; -} - -.tgl:checked+.tgl-btn:after { - left: 50%; -} - -.tgl-ios+.tgl-btn { - background: #d7d7d7; - border-radius: 2em; - padding: 2px; - transition: all .4s ease; - border: 1px solid #e8eae9; -} - -.tgl-ios+.tgl-btn:after { - border-radius: 2em; - background: #fbfbfb; - transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease; - box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 0 rgba(0, 0, 0, 0.08); -} - -.tgl-ios+.tgl-btn:hover:after { - will-change: padding; -} - -.tgl-ios+.tgl-btn:active { - box-shadow: inset 0 0 0 2em #e8eae9; -} - -.tgl-ios+.tgl-btn:active:after { - padding-right: .8em; -} - -.tgl-ios:checked+.tgl-btn { - background: #8e44ad; -} - -.tgl-ios:checked+.tgl-btn:active { - box-shadow: none; -} - -.tgl-ios:checked+.tgl-btn:active:after { - margin-left: -.8em; -} \ No newline at end of file diff --git a/popup/css/style.css b/popup/css/style.css deleted file mode 100644 index 9f2a614..0000000 --- a/popup/css/style.css +++ /dev/null @@ -1,114 +0,0 @@ -@import "button.css"; - - -*, -*::after, -*::before { - box-sizing: border-box; - font-size: 15px; - margin: 0; - padding: 0; -} - -body { - width: 250px; - margin-bottom: 0; - padding-bottom: 0; -} - -.header { - text-align: center; - font-size: 20px; - font-weight: 600; - letter-spacing: 0.9px; - padding: 15px 0px; - display: block; - background-color: #d5d5d5; -} - -.header > p { - font-size: 12px; - font-style: italic; - font-weight: 400; - margin-top: 5px; -} - -.footer { - text-align: center; - font-size: 18px; - font-weight: 600; - letter-spacing: 0.9px; - background-color: #d5d5d5; - display: block; - padding: 5px ; -} - -.footer > p { - font-size: 10px; - padding: 10px; -} - -.content { - width: 90%; - margin: auto; -} - -.row { - padding: 10px 0px 5px 0px; -} - -.form-label { - display: block; - padding: 3px 0px; - font-weight: 500; -} - -.form-control { - border: 1px solid #9c9696; - margin: auto; - border-radius: 5px; - padding: 8px 3px; - width: 100%; -} - -.show { - display: block; -} - -.hide { - display: none; -} -input:focus, button:focus { - outline: none; -} -label[for="proxyCheckBox"], input[type="checkbox"] { - cursor: pointer; -} - -.btn { - background-color: #F0F0F0; - color: #808080; - border-radius: 3px; - height: 35px; - padding: 0 10px 0 10px; - text-align: center; - cursor: pointer; - user-select: none; - border: 0px; -} - -.btn-highlight { - color: #fff; - background-color: #007bff; - border-color: #007bff -} - -.btn:disabled { - cursor: not-allowed; -} - -.short-right-label { - font-size: 10px; - float: right; - margin-right: 6px; -} \ No newline at end of file diff --git a/popup/popup.html b/popup/popup.html deleted file mode 100644 index 809bf8e..0000000 --- a/popup/popup.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - Document - - - - -
- Live Server -
- Web Extension - -

"Makes your existing server live"

-
-
-
- -
-
- - -
-
-
- -
-
- - -
-
- -
-
-
- - -
-
- -
-
- - - Install Live Server -
-
-
- -
-
-
- - - - - \ No newline at end of file diff --git a/popup/popup.js b/popup/popup.js deleted file mode 100644 index cb8211f..0000000 --- a/popup/popup.js +++ /dev/null @@ -1,63 +0,0 @@ -; (function () { - - 'use strict'; - - const liveReloadCheck = document.getElementById('liveReloadCheck'); - const noProxyCheckBox = document.getElementById('noProxyCheckBox'); - const actualServerAddress = document.getElementById('actualServer'); - const liveServerAddress = document.getElementById('liveServer'); - const submitBtn = document.getElementById('submitBtn'); - - const serverSetupDiv = document.getElementById('serverSetup'); - - function submitForm() { - const formData = { - isEnable: liveReloadCheck.checked, - proxySetup: !noProxyCheckBox.checked, - actualUrl: actualServerAddress.value || '', - liveServerUrl: liveServerAddress.value || '' - } - - chrome.runtime.sendMessage({ - req: 'set-live-server-config', - data: formData - }); - - } - - liveReloadCheck.onclick = () => { - submitForm(); - } - noProxyCheckBox.onchange = () => { - submitForm(); - } - - noProxyCheckBox.onclick = () => { - serverSetupDiv.className = noProxyCheckBox.checked ? 'show' : 'hide'; - } - - document.addEventListener('DOMContentLoaded', () => { - chrome.runtime.sendMessage({ - req: 'get-live-server-config' - }, (data) => { - if (!data) return - liveReloadCheck.checked = data.isEnable || false; - noProxyCheckBox.checked = !data.proxySetup; - actualServerAddress.value = data.actualUrl || ''; - liveServerAddress.value = data.liveServerUrl || ''; - serverSetupDiv.className = noProxyCheckBox.checked ? 'show' : 'hide'; - }); - }); - - submitBtn.onclick = () => { - submitForm(); - submitBtn.classList.remove('btn-highlight'); - submitBtn.disabled = true; - } - - liveServerAddress.onkeyup = actualServerAddress.onkeyup = () => { - submitBtn.disabled = false; - submitBtn.classList.add('btn-highlight'); - } - -})(); \ No newline at end of file diff --git a/reload.js b/reload.js deleted file mode 100644 index 0682988..0000000 --- a/reload.js +++ /dev/null @@ -1,70 +0,0 @@ -; (function () { - - 'use strict'; - - const protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; - let address = protocol + window.location.host + window.location.pathname + '/ws'; - let socket; - let isActive = false; - - function init(data) { - if (!data.proxySetup) { - //Correction - if (data.liveServerUrl.indexOf('http') !== 0) - data.liveServerUrl = 'http' + data.liveServerUrl; - if (data.actualUrl.indexOf('http') !== 0) - data.actualUrl = 'http' + data.actualUrl; - if (!data.actualUrl.endsWith('/')) - data.actualUrl = data.actualUrl + '/'; - - address = data.liveServerUrl.replace('http', 'ws') + '/ws'; - } - socket = new WebSocket(address); - socket.onmessage = (msg) => { - reloadWindow(msg, data) - }; - } - - function reloadWindow(msg, data) { - if (!isActive) return; - const currentUrl = window.location.protocol + '//' + window.location.host + window.location.pathname; - if (msg.data == 'reload' || msg.data == 'refreshcss') { - if (data.proxySetup === true || (data.proxySetup === false && currentUrl.startsWith(data.actualUrl))) { - window.location.reload(); - } - } - - logMsgForASingleTime(); - }; - - function logMsgForASingleTime() { - const key = 'oneTimeLog-live-server-web-extesion'; - if (!sessionStorage.getItem(key)) { - console.log("Live reload Actived - Live Server Web Extension"); - sessionStorage.setItem(key, 1); - } - - } - - - chrome.runtime.onMessage.addListener((msg) => { - if (typeof msg !== 'object') return; - if (msg.req === 'live-server-config-updated') { - isActive = msg.data.isEnable; - if (isActive && !socket) { - init(msg.data); - } - } - }); - - chrome.runtime.sendMessage({ - req: 'get-live-server-config' - }, (data) => { - isActive = data.isEnable; - if (isActive && !socket) { - init(data); - } - - }); - -})(); \ No newline at end of file