Soushi-Atsumi / Open-in-Sidebar

Very simple and useful extension. You can open a link in the sidebar.
https://addons.mozilla.org/en-US/firefox/addon/open_in_sidebar/
Mozilla Public License 2.0
21 stars 2 forks source link

Sidebar page URL? #14

Closed Octur1s closed 7 months ago

Octur1s commented 7 months ago

Hello, I was wondering if it is possible to access the url of the page that is currently open the sidebar. I assume that it must be stored or cached temporarily, but is there a way to view, extract or utilize it, perhaps with a js script? My thought is that it would be convenient to have a header in the sidebar that shows the url, so that it could be reopened in a normal tab.

Thank you

Soushi-Atsumi commented 7 months ago

Hi, Octur1s

Yes, accessing the url of the sidebar is possible by using a content script. However, the design of the sidebar cannot be changed because the sidebar is one of Firefox but not the extension. In conclusion, the extension can know the url of the sidebar but it cannot be displayed. An extension that copy the url of the current page may help you.

Octur1s commented 7 months ago

Thank you, I've found an extension that allows me to open the current page in the sidebar in a normal tab.

Animation2

I may just use this in combination with your extension. If you could consider adding this functionality to your own that would be great!

Thanks again

EDIT:

Hello, I've managed to make a simple extension that will open the sidebar page in a tab with this code background.js

`browser.menus.create({ id: "sidebarToTab", title: "Open in Tab", viewTypes: ["sidebar"], contexts: ["page"], icons: { "16": "image.png" } });

browser.menus.onClicked.addListener((info, tab) => { if(info.menuItemId == "sidebarToTab"){ browser.tabs.create({url: info.pageUrl}); } }); `

Soushi-Atsumi commented 7 months ago

Thanks for the example and telling the extension. This extension is very interesting. I will add the feature like you told.