Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HandcartCactus authored Jun 7, 2024
1 parent 5176c14 commit 8706a03
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
38 changes: 38 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Function to hit the back button on the given tab
* @param {Tab} tabInfo - The tab to go back on.
*/
async function goBack(tabInfo) {
let withGoBack = browser.tabs.goBack(tabInfo.id);
}

/**
* Function to handle the context menu click event.
* @param {Object} info - Information about the item clicked and the context where the click happened.
* @param {Object} tab - The details of the tab where the click took place.
*/
async function openPreviousPage(info, tab) {
try {
let duplicated = browser.tabs.duplicate(tab.id, {index: tab.index});
duplicated.then(goBack, console.log)
} catch (error) {
console.error("Error retrieving previous URL:", error);
}
}

/**
* Function to create the context menu item.
*/
function createContextMenuItem() {
browser.contextMenus.create({
id: "open-previous-page",
title: "Open Previous Page in New Tab",
contexts: ["tab"]
});
}

// Add listener for the context menu click event
browser.contextMenus.onClicked.addListener(openPreviousPage);

// Create the context menu item when the extension is installed or updated
browser.runtime.onInstalled.addListener(createContextMenuItem);
Binary file added icon/icon-48-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon/icon-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions icon/icon-prev-site-new-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"manifest_version": 3,
"name": "Open Previous Page in New Tab",
"version": "1.0",
"description": "Adds a context menu option to open the previous page of a tab in a new tab.",
"permissions": [
"contextMenus",
"history",
"tabs"
],
"background": {
"scripts": ["background.js"]
},
"icons": {
"48": "icon/icon-48-2.png"
},
"browser_specific_settings": {
"gecko": {
"id": "{c06ad177-7a43-4a29-875f-beec98bd53be}"
}
}
}

0 comments on commit 8706a03

Please sign in to comment.