From 58fc0906f1ba4952561e2af45a0a90642150c9f5 Mon Sep 17 00:00:00 2001 From: youvrajbhaskarjb-hub Date: Mon, 11 Aug 2025 16:41:00 +0530 Subject: [PATCH] Delete reload.js --- reload.js | 70 ------------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 reload.js 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