From 6ea60a0723f7c63bd62ac85576f1919dfe364099 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Tue, 7 May 2024 22:46:38 -0500 Subject: [PATCH] Added invalid url detection --- README.md | 4 ++-- src/manifest.json | 4 ++-- src/scripts/events.js | 6 ++--- src/scripts/utils.js | 56 +++++++++++++++++++++++++++---------------- src/styles/styles.css | 16 +++++++++++-- 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index e3d4bac..ce98899 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Easy Session Manager allows you to manage your Firefox session by backing up or # Download https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/ -# Version: 0.2.3.2 -* Fixed Selective Open not working properly when multiple windows are in session. +# Version: 0.2.3.3 +* Fixed tab open logic to exclude urls not valid for api opening (due to security). # Images diff --git a/src/manifest.json b/src/manifest.json index 7339d5a..d7bc1ef 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,13 +1,13 @@ { "manifest_version": 2, "name": "Easy Session Manager", - "version": "0.2.3.2", + "version": "0.2.3.3", "description": "Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.", "browser_specific_settings": { "gecko": { "id": "sessionManager@itdominator.com", - "strict_min_version": "57.0" + "strict_min_version": "79.0" } }, diff --git a/src/scripts/events.js b/src/scripts/events.js index 95c308d..cc081c0 100644 --- a/src/scripts/events.js +++ b/src/scripts/events.js @@ -5,7 +5,6 @@ document.addEventListener("click", (e) => { const target = e.target; const action = target.getAttribute("name"); - // Set selection first before doing any actions... if (target.tagName == "LI" && target.className.includes("sessionLI")) { if (selectedItem) { @@ -56,6 +55,8 @@ document.addEventListener("click", (e) => { return ; } + if (!action) return; + if (/(closeSave|closeEdit|closeDownload|closeDelete|closeConfirm|closeLoad)/.test(action)) { if (action.includes("closeSave")) { hideModal("saveModal"); @@ -70,8 +71,7 @@ document.addEventListener("click", (e) => { } else if (action.includes("closeLoad")) { hideModal("loadModal"); } - } - else if (action.includes("deselectAll")) { + } else if (action.includes("deselectAll")) { let container = document.getElementById("editSelectionContainer"); deselectAll(container); } diff --git a/src/scripts/utils.js b/src/scripts/utils.js index f47672a..012ed23 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.js @@ -40,28 +40,33 @@ const loadContainer = (sessionData, keys, keysLength, divID) => { /* Selection Process */ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => { - let container = document.createElement("DIV"); - let ulTemplate = document.querySelector('#ulTemplate'); - let liTemplate = document.querySelector('#liTemplate'); + let invalidURLsMessage = document.createElement("P") + let container = document.createElement("DIV"); + let ulTemplate = document.querySelector('#ulTemplate'); + let liTemplate = document.querySelector('#liTemplate'); + + invalidURLsMessage.innerText = "The Session has invalid URLs (highlighted for convenience). They might break loading of a session..."; + invalidURLsMessage.classList.add("warning"); for (let i = 0; i < keysLength; i++) { - let ulClone = document.importNode(ulTemplate.content, true); - let ulTag = ulClone.querySelector('.collection'); - let h2Tag = ulClone.querySelector('.ulHeader'); - let h2Txt = document.createTextNode("Window: " + (i + 1)); + let ulClone = document.importNode(ulTemplate.content, true); + let ulTag = ulClone.querySelector('.collection'); + let h2Tag = ulClone.querySelector('.ulHeader'); + let h2Txt = document.createTextNode("Window: " + (i + 1)); - let selAll = ulClone.querySelector('.selAll'); - let titleAll = ulClone.querySelector('.titleAll'); - let ulLblTag = ulClone.querySelector('.selAllLbl'); - let ulLblTag2 = ulClone.querySelector('.titleAllLbl'); - let store = json[keys[i]]; - let j = 0; + let selAll = ulClone.querySelector('.selAll'); + let titleAll = ulClone.querySelector('.titleAll'); + let ulLblTag = ulClone.querySelector('.selAllLbl'); + let ulLblTag2 = ulClone.querySelector('.titleAllLbl'); + let store = json[keys[i]]; + let j = 0; + let hasInvalidURLs = false; - container.id = "editSelectionContainer"; - selAll.id = "selectAllWin" + i; - titleAll.id = "selectAllTitle" + i; - ulLblTag.htmlFor = "selectAllWin" + i; - ulLblTag2.htmlFor = "selectAllTitle" + i; + container.id = "editSelectionContainer"; + selAll.id = "selectAllWin" + i; + titleAll.id = "selectAllTitle" + i; + ulLblTag.htmlFor = "selectAllWin" + i; + ulLblTag2.htmlFor = "selectAllTitle" + i; selAll.addEventListener("click", function (eve) { toggleSelect(eve.target, "Win" + i); @@ -72,12 +77,12 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => { toggleTitles(eve.target, "Win" + i); }); - - h2Tag.prepend(h2Txt); store.forEach(tab => { let liClone = document.importNode(liTemplate.content, true); + let liTag = liClone.querySelector("li"); let inptTag = liClone.querySelector("input"); + // link lbl let lblTag = liClone.querySelector(".linkLbl"); let labelTxt = document.createTextNode(tab.link); @@ -94,6 +99,13 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => { inptTag.setAttribute("name", "Win" + i); // Used for toggle select all + if (/(file:\/\/|ws:\/\/|wss:\/\/|moz-extension:\/\/|about:)/.test(tab.link)) { + liTag.classList.add("error-bg"); + lblTag.classList.add("error"); + lblTag2.classList.add("error"); + hasInvalidURLs = true; + } + lblTag.appendChild(labelTxt); lblTag2.appendChild(labelTxt2); @@ -102,6 +114,10 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => { j++; }); + if (hasInvalidURLs) { + container.appendChild(invalidURLsMessage); + } + container.appendChild(ulClone); } diff --git a/src/styles/styles.css b/src/styles/styles.css index d305328..b84bb21 100644 --- a/src/styles/styles.css +++ b/src/styles/styles.css @@ -11,6 +11,7 @@ ul, li { li { user-select: none; /* Non-prefixed version, currently supported by Chrome, Opera and Firefox */ + margin-bottom: 0.5em; } @@ -93,8 +94,8 @@ li { } .scroller { - scrollbar-color: #00000084 #ffffff64; - scrollbar-width: thin; + scrollbar-color: #00000084 #ffffff64; + scrollbar-width: thin; } @@ -117,3 +118,14 @@ li { background-color: rgba(41, 95, 115, 0.65); cursor: pointer; } + + +.error-bg { background-color: rgba(44, 44, 44, 0.64); } +.warning-bg { background-color: rgba(44, 44, 44, 0.64); } +.success-bg { background-color: rgba(44, 44, 44, 0.64); } + + +.error { color: rgb(170, 18, 18); } +.warning { color: rgb(255, 168, 0); } +.success { color: rgb(136, 204, 39); } +