Skip to content

Conversation

@con-dog
Copy link
Contributor

@con-dog con-dog commented Dec 9, 2024

What it does

Adds the ability for a user to optionally set kagi.com as their default new tab page, toggling the setting via a checkbox in the popup panel

Why ?

Improves the UX flow of using Kagi as your default search engine. By always opening a new tab to Kagi.com, a user gets a better search experience. Additionally the "Assistants" are more readily accessible via kagi.com

Implementation Details

  • Added checkbox to popup panel to toggle this option on/off (defaults to off)
  • Added 2 new required permissions to manifest (storage, tabs)
    • Storage permission required to store users choice across browser sessions
    • Tabs permission required to listen for creation of chrome://newtab/ and conditionally perform override
  • Touches "service_worker.js" to perform the override, and new files "popup.js", "redirect.js", "new-tab.html"

Testing

  • Tested on Chrome Version 131.0.6778.109 (Official Build) (arm64)
  • Verified that:
    • New tab override works when enabled
    • Setting persists across browser sessions
    • Setting can be toggled on/off
    • Original new tab behaviour remains when disabled

Reasons against merging

  • The normal way to add a new tab page is to override the chrome default new tab. However doing this would opt every Kagi extension user into a new tab experience (bad!)
  • To make the new tab experience optional, the only way is to use the tabs permission (listen to tab activations) combined with storage permission (perform action based on stored setting.

Screenshots

Screenshot 2024-12-09 at 8 10 02 PM

We need storage permission to store users new tab choice.
Additionally need tabs permission to override new tab page with kagi.com if user selected this option.
Simple get/set storage for the users new tab choice
Handles the actual overriding of new tab page in Chrome. Implemented as an optional change, letting the user decide, hence the check for "chrome://newtab/" and the storage key
Very simple, simply set the href of the new tab page. Note that if I followed the Chrome docs on overriding the new tab page, we wouldn't be able to give users the choice to opt-in or opt-out of this feature
@vprelovac vprelovac requested a review from PixeLInc December 13, 2024 14:02
@con-dog
Copy link
Contributor Author

con-dog commented Dec 19, 2024

Hello Kagi team, just checking in :) any chance this would be merged? I’m rocking it locally currently with no issues!

Also wondering if you have any other extensions planned in the future, how about a sidepanel extension for chrome for a global search panel? Would love to contribute more

Thank you,
Papillon

@PixeLInc
Copy link
Member

PixeLInc commented Dec 20, 2024

Hi there @con-dog, sorry for the wait.

This looks fine, but one thing that I would rather we not do is use the "tabs" permission, at least not as a 'default' permission.

We previously had this permission set on our extensions and it was not received well (kagisearch/browser_extensions#13) & (kagisearch/browser_extensions#17)

There is an optional_permissions field in the manifest which I think we should rather use.
https://developer.chrome.com/docs/extensions/reference/api/permissions

This makes it so that it requires an explicit user confirmation that they want to enable this permission and doesn't always require it and it doesn't show up in the "permissions" section of the extension.

We use this optional permissions in our other repository which hosts the firefox (and old chrome) extension, for activeTab, you can give that a look and see how that works if you're interested. (link)
The above chrome dev docs also have an example on there of doing an optional 'tabs' permission too.

Does that make sense & sound good to you?

@con-dog
Copy link
Contributor Author

con-dog commented Dec 20, 2024

Hi @PixeLInc no problem :) Good call on it not being received well. I will play around with optional_permissions for both storage and tabs.

Sounds really good to me, I will post an update tomorrow :)

Cheers,
Papillon

@con-dog
Copy link
Contributor Author

con-dog commented Dec 21, 2024

Have made those changes @PixeLInc , managed to get it down to just 1 optional_permission "tabs"

@PixeLInc
Copy link
Member

Hey there @con-dog,

Unfortunately after looking into it further, it appears that this feature actually is explicitly not allowed as per chrome store guidelines...

img

https://developer.chrome.com/docs/webstore/program-policies/api-use

If we were to want to do this, we'd have to always override the new tab page with a markup file and redirect from there (which is how other extensions that do this do it), but at that point it becomes not optional and more complicated (and also, that feels a little dodgy too).

So! Due to that, unfortunately we can't add this as to not break those rules.
(our extension has already been removed once for a fairly minor thing - best not push our luck)

Sorry about all that, I did not realize this was the case originally otherwise I would've mentioned it right away.
Thank you for doing submitting the feature regardless, though!

@con-dog
Copy link
Contributor Author

con-dog commented Dec 24, 2024

Hey @PixeLInc no worries, thats a shame that chrome don't allow this functionality. I agree an alternative approach would be too hacky to implement, and its not worth the risk of getting taken down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants