ssborbis / ContextSearch-web-ext

Search engine manager for modern browsers
337 stars 37 forks source link

cannot add search engines into firefox, or reset addon's own engine list - firefox 78.0.1 #263

Closed sign-in-smth closed 4 years ago

sign-in-smth commented 4 years ago

hi,

i just noticed, in this new firefox 78.0.1, i can no longer add engines into firefox's list in the search bar. using the 'Add to ContextSearch' menu option on input elements, i can only succeed in adding engines to the addon's own list, but not into firefox. (examples: https://www.bing.com/, https://torrentz2.is/)

secondly, the addon's own list in ContextSearch options -> Search Engines seems to have some new problems too:

also, i saw something related to search engines in firefox changelog here: https://www.mozilla.org/en-US/firefox/78.0.1/releasenotes/ any chance it somehow affected/broke things in your addon too?

thanks, your biggest fan since 2017 :)

ssborbis commented 4 years ago

Do you see any errors in the console in CS Options? It sounds like there's a bad entry in your config. Does exporting the config work? If so, send me a copy and I'll check it for errors.

zip and paste here or email to ssborbis@gmail.com

ssborbis commented 4 years ago

I checked my install, and it looks like adding engines to the Firefox One Click list is NOT working...

ssborbis commented 4 years ago

Looks like they finally removed the function for adding search engines to Firefox window.external.AddSearchProvider

That would explain the hanging when trying to add to OCSEs, but your engines should still show up as normal. I'd still like to check out your config.

sign-in-smth commented 4 years ago

so what is your current verdict? any hope for a workaround?

i don't seem to have any other issues with the addon other than the things related to the ff search engines. i can still create new engines for the CS list, like before, no problem. but i do need a way to copy these newly created/nicely customized (thanks to your UI) engines into ff, so they also work from search bar. otherwise i'd probably just have to switch from using ff search bar to the CS toolbar, but that costs one extra click before i can start typing, is why i haven't been using it until now.

if you still need my config, is that the Export button from CS options left pane?

ssborbis commented 4 years ago

i don't seem to have any other issues with the addon other than the things related to the ff search engines.

Ok, cool. No need for the config then.

I'm testing some methods now. They require the FF search bar to be enabled. Engines will need to be added the same way as standard open search engines provided on web pages. I think there will be some limitations though. No custom icons for one. They seems to default to the current page favicon

sign-in-smth commented 4 years ago

what if a page has a search box that i need, but there's no open search add engine option in ff search bar?

default favicon is probably not that big a deal, but it is important to be able to edit search URL, name, description etc.

ssborbis commented 4 years ago

what if a page has a search box that i need, but there's no open search add engine option in ff search bar?

That's what I'm working on now. Basically, I'm injecting a reference to the custom opensearch engine into the webpage so there's an engine to be added through FF. When adding a new engine through the Add Custom Search context menu item, you'd normally get the "Also add to Firefox One-Click Search Engines?" dialog. When the user selects "Yes", this will add the OpenSearch engine to the webpage, and I'll direct users to the search bar with a GIF or something to actually add it to the Firefox search bar. Still early development, but it looks doable.

Adding from the CS Search Engines manager is a bit trickier, but I'll come up with something.

ssborbis commented 4 years ago

If you can sideload, I've got something worth testing.

sign-in-smth commented 4 years ago

i must be a little rusty) i zipped the src folder and gave it to 'Install add-on from file...' but firefox says 'it appears to be corrupt'

there's both firefox_manifest.json and manifest.json in there, so no need to rename or delete anything, right?

edit: ok i seem to have fixed the installation .zip (files weren't in the root of it) but now firefox tells me 'it prevented this site from installing unverified addon' i set: xpinstall.signatures.required to false extensions.langpacks.signatures.required to false but still couldn't install

ssborbis commented 4 years ago

You'll have to go through about:debugging and install as a temp add-on

about:debugging -> This Firefox -> Load Temporary Add-on -> the zip file

Once it's loaded, don't click the Remove button ever. Just restart FF to get rid of it. Remove may remove your config.

ssborbis commented 4 years ago

The only change in the repo affects adding the engine from the CS Options -> Search Engines manager -> [ a search engine ] -> Add to Firefox One-Click Search Engines button ( green circle, plus sign ). Clicking that should make an OpenSearch engine available to install in the FF search bar

sign-in-smth commented 4 years ago

okey, thanks! i will give it a try tomorrow.

ssborbis commented 4 years ago

updates to the repo ...

popup message with image directing FF78+ users to the search bar works when fetching a custom search engine from CS options and when adding a new engine through the Add Custom Search menu.

before you test, grab the latest version

sign-in-smth commented 4 years ago

yes, it works here too, just like you say, you fixed it all again -), thank you!!

questions: (a) the situation when website is already offering its open search engine to install, but i don't like its default settings, so i create my own via search box and your UI - if i want to give it the same name as the default one, already being offered, then the newly created customized engine (with same name) doesn't show up as separate entry in search bar installation, instead it keeps showing the default one, and its the one it installs instead of the customized version that i made. (if names are different no such problem)

(b) would be nice to have option to disable the popup image directing to search bar every time. maybe like a 'don't show again checkbox'

(c) i don't quite understand some logic in the CS engine manager:

(d) why 'Restore Defaults' and 'Select File...' buttons in Search Engines manager stopped working after this API change? from what you mentioned its the function of writing to the search provider store that was removed. but don't these two features only need to read from it to get current engine list. and it seems that the reading actually does work, but only at the moment of addon installation, i did a clean install, and it was able to load the list, however failed with any new access attempts later.

basically my typical workflow used to be:

is deleting engine in FF list supposed to delete that engine in CS list? is it dependent on whether that engine is marked with the 'FF' sign in CS list? because i think i've seen it happen either way.

ssborbis commented 4 years ago

(a) That may be a problem due to some limitations in the way firefox displays opensearch engines listed in the head

(b) Sounds like a good idea. I'll add it

(c)

why Delete option is only available for engines without FF sign;

Firefox One-click Search Engines are stored by Firefox in a separate, (programmatically) inaccessible file. I can't actually delete them, but to prevent them from showing in CS, you can hide them. They're added to the CS menus automatically for convenience

how exactly an engine receives this FF sign (example, i just added a new engine to both FF and CS, but it doesn't show 'FF' in CS manager, but others do)

Engines that exist solely in the Firefox search bar, but not in CS get this tag. In order to import them fully into CS (get/edit the template, icon, params, etc) , you need to use the "Import One-Click Search Engines" button to read the file they're stored in. If they have a FF tag, they can't be edited, but they can be executed from CS

why selecting multiple engines in CS manager, and choosing Delete, doesn't work?

I just never added it. I think you can create a dummy folder, and mutli-select & move into the folder and delete that way.

why there isn't simply a Clear All button, to remove all CS engines (but not the actual FF engines, of course, in the search.json.mozlz4), so afterwards all engines could be reloaded into CS list from search.json.mozlz4.

That's mostly the function of the Restore Defaults button ( not working, just fixed it locally )

(d)

Bug. Looking into it now

ssborbis commented 4 years ago

Dunno if fixing the Restore Defaults button also fixed the Import One-Click Search Engines button, but both are working now for me. I'll update the repo in a sec and you can test. If it doesn't fix both, I may need to see your config.

What OS are you on?

sign-in-smth commented 4 years ago

i have win10 x64

about all the questions related to CS list. i just always seemed to think that it was supposed to be a completely independent / disconnected from FF list of search engines, which may, or may not, mirror FF list. i thought the original idea of CS list was simply to have an option to load the existing FF list into it, as a starting point, at first, and from there allow user to modify these two lists separately, or let him sync CS list with the FF one, tho not the other way around. thus these edit/delete operations on CS list items in my understanding never seemed to imply any sort of simultaneous modification of FF list, so shouldn't have been limited by the (programmatically) inaccessible search.json. for example when i wanted to delete some or all items from CS list i didn't mean to ask of you to delete them from FF engines as well. just wanted to be able to clear the CS list, as separate inpendent entity, say if i wanted to rebuild it from scratch, possibly again starting with loading current FF list into it.

ssborbis commented 4 years ago

Looking over the workflow you listed...

Is your CS menu simply a mirror of the Firefox search bar with no additional engines / folders?

I suppose I could add a sync button or option to at least respect / mirror the order of the Firefox list (I'll have to double-check the API). This obviously gets undoable when you add in CS folders and CS engines that aren't in the Firefox search bar. It's convoluted, but that's a result of there being no API to directly modify the Firefox search engines. It's read-only, and even that is limited.

sign-in-smth commented 4 years ago

yes, i keep CS list exactly the same as FF list. if there were an auto-sync option, it'd be nice, would be no need to click Restore Defaults each time i change something in FF list.

anyways, it appears that your implementation of CS list may be different, more complex than i thought. i'll just keep trying to wrap my head around it.

i tried to say the other day, that even though, yes, FF list is read-only, but if we create a copy of it in CS list, then there shouldn't be any limitations as to what we can do with those copied engines inside CS list, like modify, delete some or clear all of them - because we'd be doing these things only with the copies of these engines, only inside CS list. while at that time everything remains intact and the same in the read-only FF list. thats why it seemed surprising to me why some things weren't allowed in CS list.

but i must be missing some important points here, i'll probably just see it later. so no worries, i'm just glad everything is working again like before. thank you very much for the help and support !!

ssborbis commented 4 years ago

Do you ever modify search engines through this add-on? Like, edit the params, icons, etc?

Maybe I need a "Basic" mode for Firefox that just mirrors the FF search bar. Since the search API was added (FF63), the NEED to maintain a separate list of search engines is gone. A user could rely solely on the FF engines. But power users would definitely need to build and maintain an engine list in CS.

Basic mode could disable the search engines manager and refer the user to the FF search options and streamline the Add Custom Search dialogs.

sign-in-smth commented 4 years ago

i edit the params, but only once when creating new engine via Add Custom Search, then let it place it both into FF and CS lists. then rearrange the engines in FF search options, then hit Restore Defaults in CS list to make it mirror the new order from FF. so for me such Basic mode would probably be best fit, would eliminate that final step.

so that must be what i failed to understand, the engines with FF tag, they are like shortcuts, not actual copies, and hence the editing limitations, is that it? what is the advantage of doing that, instead of always creating full copies of all engines for CS list, like before FF63?

ssborbis commented 4 years ago

so that must be what i failed to understand, the engines with FF tag, they are like shortcuts, not actual copies, and hence the editing limitations, is that it?

Exactly

what is the advantage of doing that, instead of always creating full copies of all engines for CS list, like before FF63?

The advantage is you don't have to do anything to use those engines. They're available to CS automatically thanks to the search API. You don't need to click the Import One-Click Search Engines and browse to your search.json.mozlz4 file. Not every user wants / is competent to go through that step.

sign-in-smth commented 4 years ago

lol i must be that rare person on whom simplification like that only becomes a cause of confusion. i'm really sorry for my previous questions)

ssborbis commented 4 years ago

No worries.

I just made a push to the repo. The latest has an option under CS Options -> Search Engines to sync to firefox search. In short, it overrides the manager and mirrors the Firefox search in the context menu and the tiled menus. Needs testing, but it looks functional.

Still thinking through the opensearch issues.

ssborbis commented 4 years ago

Damn, looks like there's no way to tell which engines have been hidden. Come on Mozilla

sign-in-smth commented 4 years ago

today's my beer break day -) but i will surely want to try new version tomorrow. looking forward to it -)

sign-in-smth commented 4 years ago

Damn, looks like there's no way to tell which engines have been hidden. Come on Mozilla

it seems it's not stored inside search.json.mozlz4, right? but elsewhere. without that, will you have to disable this entire Basic mode feature in release version?

could you pls explain why i'm getting different sets of FF default engines depending on how i load the FF list? here's 6 default engines loaded via Select File... (and that's exactly what's inside my search.json, if viewed in text editor) select file - default engines however, here's 12 default engines loaded via Restore Defaults restore defaults - default engines

also, could you pls make CS honor _metaData -> hidden: true flag, when loading from search.json.mozlz4? it's removed default built-in engines ( _isBuiltin: true), FF doesn't really erase them but only sets that flag, and doesn't display them anymore. i think CS should auto-set Hidden status on these engines in CS list too. that would concern the 6 default engines from Select File option as per the previous question. the same should probably apply to the 12 default engines from Restore Defaults, but i dont know where these 12 come from.

edit: one other request, i'd really love to have an Always Hide toggle for engines on the CS list. so if enabled that engine preserves Hidden status even after Restore Defaults/Select file/Basis mode auto-sync. so it only gets unhidden manually by toggling again. because i have one engine that i need enabled in FF list, but disabled in CS.

ssborbis commented 4 years ago

Restore Defaults restores the default CS list ( the engines included with this add-on ). No consideration of the FF list.

_metaData -> hidden: true

I don't see that flag in my search.json.mozlz4 file anywhere.

sign-in-smth commented 4 years ago

Untitled

ssborbis commented 4 years ago

My profile may be using an outdated search.json.mozlz4 structure. I don't have that property. I'll add the check even if I can't use it.

Untitled

sign-in-smth commented 4 years ago

maybe it's not just disabling (unchecking) a built-in engine that gets this property added. but clicking Remove on that engine? i only have it on the removed+builtin engines.

ssborbis commented 4 years ago

Ah, ok that makes sense. The engines hidden via checkmark are recorded in prefs.js so I can't read them through this add-on without another upload action. That will have to do for now.

The update in the repo should check for the isHidden flag and hide that engine in CS, but I haven't tested it.

sign-in-smth commented 4 years ago

The update in the repo should check for the isHidden flag and hide that engine in CS

yep, that worked !

oh another question i forgot, it will never be possible for quick menu to work inside FF pdf viewer, because its not a web page?

ssborbis commented 4 years ago

oh another question i forgot, it will never be possible for quick menu to work inside FF pdf viewer, because its not a web page?

I haven't looked at the pdf renderer in a long time, but last I did it wouldn't work because there was no DOM to attach to. Like you said, it's not a web page. I'll take another look to see if anything's changed.

(edit) looks like it's still being worked out https://bugzilla.mozilla.org/show_bug.cgi?id=1454760

ssborbis commented 4 years ago

Latest push has 2 changes

  1. The "Also add to Firefox?" prompt shouldn't appear when using the context menu to add a new engine if the engine already exists in the FF search bar

  2. A new tab should open when trying to add an opensearch engine on a page that already includes one of the same name ( I've only minimally tested this through CS options -> Search Engines -> [engine] -> Install to Firefox One-click search engines)

sign-in-smth commented 4 years ago
1. The "Also add to Firefox?" prompt shouldn't appear ...

here it still asked "Also add to Firefox?". then, if creating in same tab it hanged, if creating in other tab, as in (2.) below, it opened blank tab without new engine installation option in search bar

2. A new tab should open ...

that worked !

ssborbis commented 4 years ago

here it still asked "Also add to Firefox?". then, if creating in same tab it hanged, if creating in other tab, as in (2.) below, it opened blank tab without new engine installation option in search bar

Can you walk me through how to reproduce this? It's working as expected for me.

Here's my workflow after adding GitHub to Firefox through the FF search bar, so there's already a FF search engine loaded. Adding an engine to CS this way ( while somewhat unnecessary ) skips the "Install to Firefox?" prompt.

exists

ssborbis commented 4 years ago

Adding both a CS engine and FF engine on a webpage that has an existing opensearch engine ...

full_install

ssborbis commented 4 years ago

Adding an engine to a page with no opensearch engine available...

no_ose

sign-in-smth commented 4 years ago

here it still asked "Also add to Firefox?". then, if creating in same tab it hanged, if creating in other tab, as in (2.) below, it opened blank tab without new engine installation option in search bar

Can you walk me through how to reproduce this? It's working as expected for me.

it seems it's because i always go the Advanced -> Create route when adding new engines. tried with today's repo too.

Adding both a CS engine and FF engine on a webpage that has an existing opensearch engine ...

Adding an engine to a page with no opensearch engine available...

that and that works, i know, thats what i said the other time.

sign-in-smth commented 4 years ago

another old question i've had for ages, is there a setting to lock quick menu engine buttons in place? sometimes i click wrong one accidentally, and trying to move mouse to the one i meant to click (without releasing) end up dragging the first one.

ssborbis commented 4 years ago

it seems it's because i always go the Advanced -> Create route when adding new engines. tried with today's repo too.

Ok, I'll try that

another old question i've had for ages, is there a setting to lock quick menu engine buttons in place? sometimes i click wrong one accidentally, and trying to move mouse to the one i meant to click (without releasing) end up dragging the first one.

No, but I can add that option

ssborbis commented 4 years ago

I did some cleanup on the Create Custom menus action and added quickMenuTilesDraggable to the advanced menu

sign-in-smth commented 4 years ago

yes, Create now works as expected here too. for the quickMenuTilesDraggable i'm very-very grateful !

i have something else off-topic, i'm sorry but it just seemed cool, so - say, if a search box were not in a web page but in another firefox extension. could it ever theoretically somehow be placed into our FF/CS lists or not? like this pretty little addon that searches through all comments in a youtube video: https://addons.mozilla.org/en-US/firefox/addon/youtube-comment-search/

ssborbis commented 4 years ago

if a search box were not in a web page but in another firefox extension. could it ever theoretically somehow be placed into our FF/CS lists or not?

It depends on how the add-on interacts with the page. That one you linked for example could sorta-kinda work because it's not injected via iframe ( it's a plain DIV in the webpage BODY ), but I don't think the popup window could be triggered programmatically by another add-on. My guess is extension shortcuts ( CTRL+ALT+S in this case ) are isolated from access via Evnet.dispatchEvent( KeyboardEvent ) methods, meaning for that add-on, you'd have to open the popup manually before searching via CS, which kinda defeats the purpose.

sign-in-smth commented 4 years ago

ok, thank you for the explanation. i just had a bit of a dim hope that maybe some kind of a generic universal solution might exist. of course making custom/possibly partial new solutions every time for every new addon makes zero sense.

ssborbis commented 4 years ago

release v1.24 is available from Mozilla

jed84 commented 4 years ago

Brilliant! Works as intended.

Thanks!

sign-in-smth commented 4 years ago

release v1.24 is available from Mozilla

thank you for the release version!

what about the two hiding features for CS list, i asked somewhere in the previous posts.

its because whenever i need to reset CS list i have to repeat the above two hiding steps every time

ssborbis commented 4 years ago

option to keep the 12 CS default engines hidden upon Restore Defaults and Basic mode auto-sync;

Why are you wanting this? I thought you said you only use the engines installed to the Firefox search bar