Added invalid url detection

This commit is contained in:
itdominator 2024-05-07 22:46:38 -05:00
parent b433161d72
commit 6ea60a0723
5 changed files with 57 additions and 29 deletions

View File

@ -4,8 +4,8 @@ Easy Session Manager allows you to manage your Firefox session by backing up or
# Download # Download
https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/ https://addons.mozilla.org/en-US/firefox/addon/easy-session-manager/
# Version: 0.2.3.2 # Version: 0.2.3.3
* Fixed Selective Open not working properly when multiple windows are in session. * Fixed tab open logic to exclude urls not valid for api opening (due to security).
# Images # Images

View File

@ -1,13 +1,13 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Easy Session Manager", "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.", "description": "Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.",
"browser_specific_settings": { "browser_specific_settings": {
"gecko": { "gecko": {
"id": "sessionManager@itdominator.com", "id": "sessionManager@itdominator.com",
"strict_min_version": "57.0" "strict_min_version": "79.0"
} }
}, },

View File

@ -5,7 +5,6 @@ document.addEventListener("click", (e) => {
const target = e.target; const target = e.target;
const action = target.getAttribute("name"); const action = target.getAttribute("name");
// Set selection first before doing any actions... // Set selection first before doing any actions...
if (target.tagName == "LI" && target.className.includes("sessionLI")) { if (target.tagName == "LI" && target.className.includes("sessionLI")) {
if (selectedItem) { if (selectedItem) {
@ -56,6 +55,8 @@ document.addEventListener("click", (e) => {
return ; return ;
} }
if (!action) return;
if (/(closeSave|closeEdit|closeDownload|closeDelete|closeConfirm|closeLoad)/.test(action)) { if (/(closeSave|closeEdit|closeDownload|closeDelete|closeConfirm|closeLoad)/.test(action)) {
if (action.includes("closeSave")) { if (action.includes("closeSave")) {
hideModal("saveModal"); hideModal("saveModal");
@ -70,8 +71,7 @@ document.addEventListener("click", (e) => {
} else if (action.includes("closeLoad")) { } else if (action.includes("closeLoad")) {
hideModal("loadModal"); hideModal("loadModal");
} }
} } else if (action.includes("deselectAll")) {
else if (action.includes("deselectAll")) {
let container = document.getElementById("editSelectionContainer"); let container = document.getElementById("editSelectionContainer");
deselectAll(container); deselectAll(container);
} }

View File

@ -40,10 +40,14 @@ const loadContainer = (sessionData, keys, keysLength, divID) => {
/* Selection Process */ /* Selection Process */
const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => { const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
let invalidURLsMessage = document.createElement("P")
let container = document.createElement("DIV"); let container = document.createElement("DIV");
let ulTemplate = document.querySelector('#ulTemplate'); let ulTemplate = document.querySelector('#ulTemplate');
let liTemplate = document.querySelector('#liTemplate'); 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++) { for (let i = 0; i < keysLength; i++) {
let ulClone = document.importNode(ulTemplate.content, true); let ulClone = document.importNode(ulTemplate.content, true);
let ulTag = ulClone.querySelector('.collection'); let ulTag = ulClone.querySelector('.collection');
@ -56,6 +60,7 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
let ulLblTag2 = ulClone.querySelector('.titleAllLbl'); let ulLblTag2 = ulClone.querySelector('.titleAllLbl');
let store = json[keys[i]]; let store = json[keys[i]];
let j = 0; let j = 0;
let hasInvalidURLs = false;
container.id = "editSelectionContainer"; container.id = "editSelectionContainer";
selAll.id = "selectAllWin" + i; selAll.id = "selectAllWin" + i;
@ -72,12 +77,12 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
toggleTitles(eve.target, "Win" + i); toggleTitles(eve.target, "Win" + i);
}); });
h2Tag.prepend(h2Txt); h2Tag.prepend(h2Txt);
store.forEach(tab => { store.forEach(tab => {
let liClone = document.importNode(liTemplate.content, true); let liClone = document.importNode(liTemplate.content, true);
let liTag = liClone.querySelector("li");
let inptTag = liClone.querySelector("input"); let inptTag = liClone.querySelector("input");
// link lbl // link lbl
let lblTag = liClone.querySelector(".linkLbl"); let lblTag = liClone.querySelector(".linkLbl");
let labelTxt = document.createTextNode(tab.link); 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 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); lblTag.appendChild(labelTxt);
lblTag2.appendChild(labelTxt2); lblTag2.appendChild(labelTxt2);
@ -102,6 +114,10 @@ const generateSelectionWindow = (json = "", keys = null, keysLength = 0) => {
j++; j++;
}); });
if (hasInvalidURLs) {
container.appendChild(invalidURLsMessage);
}
container.appendChild(ulClone); container.appendChild(ulClone);
} }

View File

@ -11,6 +11,7 @@ ul, li {
li { li {
user-select: none; /* Non-prefixed version, currently user-select: none; /* Non-prefixed version, currently
supported by Chrome, Opera and Firefox */ supported by Chrome, Opera and Firefox */
margin-bottom: 0.5em;
} }
@ -117,3 +118,14 @@ li {
background-color: rgba(41, 95, 115, 0.65); background-color: rgba(41, 95, 115, 0.65);
cursor: pointer; 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); }