Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
.idea/
.vscode
package-lock.json
node_modules
node_modules/
.DS_Store
43 changes: 26 additions & 17 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
function logTabs(windowInfo) {
return windowInfo.id;
}
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.message === "restore_session") {
restoreSession(request.urls);
}
});

function onError(error) {
return;
}
async function restoreSession(urls) {
if (!urls || urls.length === 0) return;

try {
let windowInfo = await browser.windows.getLastFocused({ windowTypes: ["normal"] });

if (!windowInfo) {
const windows = await browser.windows.getAll({ windowTypes: ["normal"] });
if (windows.length > 0) {
windowInfo = windows[0];
} else {
windowInfo = await browser.windows.create({ url: urls[0] });
urls = urls.slice(1);
}
}

browser.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if( request.message === "restore_session" ) {
request.urls.forEach(function(url){
var winID = browser.windows.getLastFocused({"windowTypes": ["normal"]}).then(logTabs, onError);
winID.then(function(result){
var createTab = browser.tabs.create({"windowId": result, "url": url});
});
});
for (const url of urls) {
await browser.tabs.create({ windowId: windowInfo.id, url: url });
}
} catch (error) {
console.error(`Error restoring session: ${error}`);
}
}
);
}
18 changes: 12 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "session-resurrection",
"version": "1.5",
"version": "1.6",
"description": "Save your browser sessions and reload them any time",
"icons": {
"48": "icons/sess-res-48.png"
},
"permissions": ["activeTab", "tabs", "storage", "<all_urls>", "webRequest"],
"browser_action": {
"permissions": [
"tabs",
"storage",
"activeTab"
],
"action": {
"default_icon": "icons/sess-res-48.png",
"default_title": "Session Resurrection",
"default_popup": "/sessions-pop-up/index.html"
"default_popup": "sessions-pop-up/index.html"
},
"background": {
"scripts": ["/background.js"]
"scripts": [
"background.js"
]
}
}
48 changes: 48 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "session-resurrection",
"version": "1.6.0",
"description": "<p align=\"center\"> <a href=\"https://addons.mozilla.org/en-US/firefox/addon/session-resurrection\" target=\"_blank\"> <img src=\"https://img.shields.io/badge/Firefox-Addon-orange.svg\" alt=\"Download\"> </a> <a href=\"#\"> <img src=\"https://img.shields.io/badge/Made-while%20rewatching%20Frisky%20Dingo-9C599C.svg\" alt=\"Made while rewatching Frisky Dingo\"> </a> </p>",
"main": "background.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"copy-deps": "cp node_modules/jquery/dist/jquery.min.js sessions-pop-up/jquery.min.js && cp node_modules/@materializecss/materialize/dist/css/materialize.min.css sessions-pop-up/materialize/css/materialize.min.css && cp node_modules/@materializecss/materialize/dist/js/materialize.min.js sessions-pop-up/materialize/js/materialize.min.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/TheAdnan/Session-resurrection.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"bugs": {
"url": "https://github.com/TheAdnan/Session-resurrection/issues"
},
"homepage": "https://github.com/TheAdnan/Session-resurrection#readme",
"dependencies": {
"@materializecss/materialize": "^2.3.3",
"jquery": "^4.0.0"
}
}
42 changes: 42 additions & 0 deletions sessions-pop-up/fonts/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@font-face {
font-family: 'Nunito';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url('nunito-400.ttf') format('truetype');
}
@font-face {
font-family: 'Nunito';
font-style: normal;
font-weight: 600;
font-display: swap;
src: url('nunito-600.ttf') format('truetype');
}
@font-face {
font-family: 'Nunito';
font-style: normal;
font-weight: 800;
font-display: swap;
src: url('nunito-800.ttf') format('truetype');
}

@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url('material-icons.ttf') format('truetype');
}

.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
}
Binary file added sessions-pop-up/fonts/material-icons.ttf
Binary file not shown.
Binary file added sessions-pop-up/fonts/nunito-400.ttf
Binary file not shown.
Binary file added sessions-pop-up/fonts/nunito-600.ttf
Binary file not shown.
Binary file added sessions-pop-up/fonts/nunito-800.ttf
Binary file not shown.
16 changes: 14 additions & 2 deletions sessions-pop-up/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Session Resurrection</title>
<link rel="stylesheet" href="materialize/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="fonts/fonts.css">
<link rel="stylesheet" href="style.css">
<script src="jquery-3.2.1.min.js"></script>
<script src="jquery.min.js"></script>
<script src="materialize/js/materialize.min.js"></script>
<script src="save-session.js"></script>
</head>
Expand Down Expand Up @@ -72,6 +72,18 @@ <h4 id="_ao_title">Session Resurrection</h4>
<a href="https://github.com/TheAdnan"><img src="Octocats/Octocat/Octocat.jpg" height="30px" width="30px"></a><span style="margin-left: 0.7em;">Connect with the developer!</span>
</div>
</div>

<!-- Confirmation Modal -->
<div id="_ao_confirm_modal" class="modal">
<div class="modal-content">
<h4 id="_ao_confirm_title">Confirm Action</h4>
<p id="_ao_confirm_message">Are you sure you want to proceed?</p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-close waves-effect waves-red btn-flat">Cancel</a>
<a href="#!" id="_ao_confirm_yes_btn" class="modal-close waves-effect waves-green btn-flat">Yes</a>
</div>
</div>
</body>

</html>
4 changes: 0 additions & 4 deletions sessions-pop-up/jquery-3.2.1.min.js

This file was deleted.

2 changes: 2 additions & 0 deletions sessions-pop-up/jquery.min.js

Large diffs are not rendered by default.

19 changes: 6 additions & 13 deletions sessions-pop-up/materialize/css/materialize.min.css

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions sessions-pop-up/materialize/js/materialize.min.js

Large diffs are not rendered by default.

Loading