Updated in place tab loading logic
This commit is contained in:
parent
1b72ae63d2
commit
27e6890d04
|
@ -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.5
|
||||
* Updated prompting text
|
||||
# Version: 0.2.3.6
|
||||
* Updated in place tab loading logic
|
||||
|
||||
|
||||
# Images
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Easy Session Manager",
|
||||
"version": "0.2.3.5",
|
||||
"version": "0.2.3.6",
|
||||
"description": "Easy Session Manager allows you to manage your Firefox session by backing up or loading your saved sessions.",
|
||||
|
||||
"browser_specific_settings": {
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
const sanitaize = {
|
||||
encode: str => {
|
||||
str = str || "";
|
||||
return str
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
},
|
||||
decode: str => {
|
||||
str = str || "";
|
||||
return str
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'")
|
||||
.replace(/&/g, "&");
|
||||
}
|
||||
};
|
||||
|
||||
let parameter = returnReplaceParameter(location.href);
|
||||
|
||||
document.title = parameter.title;
|
||||
document.getElementsByClassName("title")[0].innerText = parameter.title;
|
||||
document.getElementsByClassName("replacedUrl")[0].value = parameter.url;
|
||||
|
||||
if (parameter.favIconUrl === "" || parameter.favIconUrl === "undefined") {
|
||||
parameter.favIconUrl = "../icons/nofavicon.png";
|
||||
}
|
||||
|
||||
document.head.insertAdjacentHTML(
|
||||
"beforeend",
|
||||
`<link rel="shortcut icon" href="${sanitaize.encode(parameter.favIconUrl)}">`
|
||||
);
|
||||
document.body.dataset.theme = parameter.theme || "light";
|
||||
|
||||
const copy = () => {
|
||||
const url = document.querySelector(".replacedUrl");
|
||||
url.select();
|
||||
document.execCommand("Copy");
|
||||
document.querySelector(".copyButton").innerText = browser.i18n.getMessage("copiedLabel");
|
||||
};
|
||||
|
||||
document.querySelector(".copyButton").onclick = copy;
|
||||
document.querySelector(".copyButton").innerText = browser.i18n.getMessage("copyUrlLabel");
|
||||
|
||||
if (parameter.state == "open_faild") {
|
||||
document.getElementsByClassName("replacedPageMessage")[0].innerText = browser.i18n.getMessage(
|
||||
"replacedPageMessage"
|
||||
);
|
||||
}
|
||||
|
||||
function returnReplaceParameter(url) {
|
||||
let parameter = {};
|
||||
let paras = url.split("?")[1].split("&");
|
||||
for (let p of paras) {
|
||||
parameter[p.split("=")[0]] = decodeURIComponent(p.split("=")[1]);
|
||||
}
|
||||
|
||||
return parameter;
|
||||
}
|
|
@ -245,9 +245,32 @@ const loadSession = (json = null, replaceTabs = false) => {
|
|||
|
||||
// First load tabs to current window.
|
||||
let store = json[keys[0]];
|
||||
store.forEach(tab => {
|
||||
tabsApi.create({ url: tab.link });
|
||||
for (let i = 0; i < store.length; i++) {
|
||||
let createOption = (store[i].link !== "about:newtab") ?
|
||||
{
|
||||
active: false,
|
||||
discarded: true,
|
||||
pinned: false,
|
||||
url: store[i].link,
|
||||
index: i + 1
|
||||
}
|
||||
: { };
|
||||
|
||||
|
||||
tabsApi.create(createOption).catch( async (e) => {
|
||||
createOption.url = returnReplaceURL(
|
||||
"open_faild",
|
||||
store[i].title,
|
||||
store[i].link,
|
||||
"../images/icons/error.png"
|
||||
);
|
||||
|
||||
await tabsApi.create(createOption);
|
||||
});
|
||||
}
|
||||
|
||||
let tab = json[keys[0]].at(-1);
|
||||
tabsApi.update(tab.id, { active: true });
|
||||
tabsApi.remove(wasCurrentTabId);
|
||||
|
||||
// If more than one window, load tabs to new windows.
|
||||
|
|
Loading…
Reference in New Issue