vim-vixen icon indicating copy to clipboard operation
vim-vixen copied to clipboard

Use the browser search engine settings

Open dannycolin opened this issue 8 years ago • 9 comments
trafficstars

I'm opening this issue because:

  • [ ] I'll report a bug
  • [x] I'll propose a new feature

Description

Use the browser search engine settings instead of Google as the default search engine. If the user choose to use a different search engine or if he delete Google from the search engine list the plugin should respect the user choice.

Failure Information (for bugs)

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. step 1
  2. step 2
  3. you get it...

System configuration

  • Operating system:
  • Firefox version:
  • Vim-Vixen version:

Console logs

Any relevant log in developer tools:

dannycolin avatar Oct 28 '17 04:10 dannycolin

It might a limitation of WebExtensions API.

ueokande avatar Oct 28 '17 08:10 ueokande

Oh yeah. I did'nt think about that new WebExtension thing :). Anyway, after a quick search I've found that there's a feature request on the Mozilla Bugzilla.

An other option, would be to create a page or a menu for the addon where we could choose the default search engine from the list that is present in the addon.

dannycolin avatar Oct 28 '17 15:10 dannycolin

Oh I forgot that https://github.com/Smile4ever/webext-experiment-searchengines I've got that link from the #extdev channel on the Mozilla IRC.

dannycolin avatar Oct 28 '17 16:10 dannycolin

I'm using "Shortkeys (Custom Keyboard Shortcuts) for Firefox" addon and the builtin keyboard shortcut ctrl+l as suggested by the developer to get around this. Simply remap "t" in vim vixen settings to something random, then add a shortcut in the aforementioned addon to open a new tab. REgards,

reading123 avatar Nov 16 '17 17:11 reading123

You're probably aware of it, but just to mention it: Firefox already supports defining short commands for search engines (Right click some search field, ~"Add keyword for this search"). It would be nice if that list could be used as a fallback if no shortcut is defined in Vim Vixen.

jcaesar avatar Jan 25 '18 17:01 jcaesar

Until there is a proper API for this, I found that

function mangle(bookmarks, se) {
	bookmarks.forEach(function(bookmark) {
		if (bookmark.type == 'bookmark' && bookmark.url.includes("%s")) {
			var shorty = new URL(bookmark.url).hostname.split('.').filter(function (l) { return l != "www" && !(l in se); })[0]; // Do not put in production, this may fail!
			se[shorty] = bookmark.url.replace(/%s/, '{}');
		}
		if (bookmark.children)
			mangle(bookmark.children, se);
	});
}

browser.bookmarks.getTree().then(
	function (bookmarks) {
		var se = {};
		mangle(bookmarks, se);
		console.log(JSON.stringify(se, undefined, 2));
	},
	function(error) {
		console.log(`An error: ${error}`);
	}
);

/* has to be placed in the background script of a web extension */

can provide a somewhat decent workaround for initially populating vim vixens search engine configuration. It can't, however, extract the correct search keywords.

jcaesar avatar Mar 13 '18 15:03 jcaesar

Heya, came here to see if there was an open PR and found this issue. Looks like, as of Firefox 63, there is a new search API for WebExtensions.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/search/get

This should allow us to grab the default search engine on Vim Vixen load.

Also, we should be able to offload the actual search functionality to the browser using

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/search/search

Which can open a search using either the default search engine or a user provided search engine.

retrohacker avatar Oct 27 '18 19:10 retrohacker

@jcaesar Don't know why Firefox doesn't provide an api to access the bookmark's keyword field. I think It's quite useful. #206 and #656 are same issues on this.

@retrohacker search.search will open the page in a tab directly. This is not consistent with vim vixen's working flow now.

chen-chao avatar Nov 05 '19 02:11 chen-chao

Heyho, it seems this issue is stalling - I would love to see it implemented :)

xeruf avatar Feb 25 '21 15:02 xeruf