Skip to content

Instantly share code, notes, and snippets.

@h-h-h-h
Last active December 1, 2018 17:13
Show Gist options
  • Save h-h-h-h/89e7bf173a901dae8427e336575f960c to your computer and use it in GitHub Desktop.
Save h-h-h-h/89e7bf173a901dae8427e336575f960c to your computer and use it in GitHub Desktop.
Add JS++ search engine in Firefox
//i This code adds a custom search engine in Firefox that utilizes Google and
//i restricts the scope of the search to the JS++ documentation.
//i
//i Tested with Firefox Developer Edition v64.
//i
//i For more information about the language, see: https://www.onux.com/jspp/
//i
//i How to run:
//i - Open the browser settings and go to "One-click Search Engines."
//i - From the hamburger menu on the browser toolbar,
//i choose "Developer" > "Toggle Tools."
//i - In the developer tools, click the "Console" tab.
//i - Paste this code and hit enter.
//i - A new search engine should have appeared on the settings page.
//i - For troubleshooting, look here whether I missed to mention something
//i necessary: https://www.reddit.com/r/firefox/comments/7fr039/how_to_add_custom_search_engines/dqelr3g/
//i
//i The search engine can be removed by means of the user interface.
Services.search.addEngineWithDetails(
/*name:*/ "JS++ Docs",
/*iconURL:*/ "https://www.onux.com/jspp/favicon.ico",
/*alias:*/ "jspp",
/*description:*/ "Google search on docs.onux.com",
/*method:*/ "GET",
/*url:*/ "https://www.google.com/search?q={searchTerms}+++++site%3Adocs.onux.com"
//i In contrast to what is documented on an unofficial page[1], the
//i `sitesearch` URL parameter shows up in the search page's text box as a
//i `site:...` constaint (Dec. 2018). So, we include the constraint in the
//i query and set it apart from the search terms.
//i
//i [1] https://github.com/NikolaiT/GoogleScraper/blob/master/GoogleScraper/search_engine_parameters.py
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment