Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Page Action Setting (icon in URL bar) #931

Closed
wants to merge 1 commit into from

Conversation

KaceCottam
Copy link

Adds a setting in the general options to enable the icon in the URL bar that brings up the same popup as the extension button.

This is a very simple version that enables the button on every page, but we can tune it to only show this icon on libredirect-compatible pages. We can also edit the wording, it is not very user friendly-- but I wonder how we should name something like this.

image
image
image

@KaceCottam
Copy link
Author

Still have to:

  • Test on Chrome/Chromium based browser
  • Update Text/Localization for each language
  • Enable only on libredirect-compatible pages

@IkelAtomig
Copy link
Member

It is a good idea, we could merge it, without even looking on it for the third task, I think it unnecessary because, we have preferred instance option which works irrespective of the site or instance you have selected.

It is something to think about.

@KaceCottam
Copy link
Author

The third task is there because at the moment, that icon will even show up on any page even if it is not relevant. Websites like AirBNB, flight trackers, online shopping, etc. will have the icon, but it doesn't make sense for it to be there contextually.

@IkelAtomig
Copy link
Member

Okay, What about a situation where you receive a instance link being shared which is not in the list.

How do you know when to show it by reading the contents of the page ?

@ManeraKai
Copy link
Member

ManeraKai commented Jun 7, 2024

I think the reason I didn't implement this was that url bar icons got removed in manifest v3.

@IkelAtomig
Copy link
Member

I don't think so. Then how would Multi Account Containers would be still then. Stuck on Mv2 ?

@KaceCottam
Copy link
Author

https://developer.chrome.com/docs/extensions/mv2/reference/pageAction
Availability
≤ MV2

Ah, didn't realize that would be the case with manifest-v3. I wonder if Firefox will follow-suit. In any case, this kind of addition might be best for a personal fork ( in the case that I am staying on my current version of firefox :P )

I also wanted to answer:

What about a situation where you receive a instance link being shared which is not in the list

In these situations, I was going to look at the code for the popup--how we determine to the top items in
image
and
image

If we can figure it out in the popup, there must be a way to say "are we in a libredirect-compatible page that is in the list" and hide the pageAction.

@IkelAtomig
Copy link
Member

I mean how do you figure it out ?

Currently pageAction is done by the URL not the page's contents

browser.tabs.onUpdated.addListener(async (id, changeInfo, tabInfo) => {
const { pageAction } = await utils.getOptions()
if (!pageAction) return;
browser.pageAction.show(tabInfo.id);
Copy link
Author

@KaceCottam KaceCottam Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
browser.pageAction.show(tabInfo.id);
const url = new URL(tabInfo.url)
await servicesHelper.computeService(url).then(r => {
if (r) {
browser.pageAction.show(id)
}
})

I mean how do you figure it out ?

Currently pageAction is done by the URL not the page's contents

This correctly detects if we are using a service that can be redirected with libredirect. I tested it with reddit, youtube, tenor, and github. There may be some failure points, but it seems to do the trick on the initial test. On websites like HBO max it would not show the page action.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, you are inspecting page data or what ?

I am confused between ID and URL right now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to inspect page content-- this is solely based on the URL of the tab.
show(id) tells the browser to show the page action (button in the address bar) for that tab identifier:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/Tab#id

It looks like servicesHelper.computeServices can take that url and figure out if it is a reddit link (or one of the alternative reddit types), or if it is a youtube, tenor, etc/alternative service.
It is based on this bit of code: https://github.com/libredirect/browser_extension/blob/32dc67db284b5803c9925df07f2cc47127acfdf6/src/pages/popup/popup.js#L109C3-L115C4

@ManeraKai
Copy link
Member

Ah, didn't realize that would be the case with manifest-v3. I wonder if Firefox will follow-suit. In any case, this kind of addition might be best for a personal fork ( in the case that I am staying on my current version of firefox :P )

I'll close it for this reason.

@ManeraKai ManeraKai closed this Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants