Giter VIP home page Giter VIP logo

search-extension-core's Introduction

Search Extension Core

license-mit license-apache

This is the core source code repository for search extensions, written in vanilla Javascript.

Overview

A list of search extensions based on this project:

Everyone can build their search extension with this project. Here are some awesome search extensions from the community:

API

Warning

The Manifest V2 will be sunset near soon, we should migrate to Manifest V3.

The manifest_v3.jsonnet is the latest manifest file for V3.

Another big concern is that V3 doesn't support localStorage, the alternative is chrome.storage.local or chrome.storage.sync.

Omnibox

constructor(defaultSuggestion, maxSuggestionSize)

let omnibox = new Omnibox(
    // The default suggestion title.
    defaultSuggestion="A handy search extension.",
    // Max suggestion size for per page.
    maxSuggestionSize=8,
);

bootstrap(config)

Bootstrap the omnibox.

  • config: The configuration object to bootstrap the Omnibox.
{
    // The default global search function
    onSearch: function(query){},
    onFormat: function(index, item){},
    onAppend: function(query){},
    onEmptyNavigate: function(content, disposition) {},
    beforeNavigate: function(content) {},
    afterNavigated: function(query, result) {},
}
  • config.onSearch: A hook function to perform the default search.
  • config.onFormat: A hook function to format the search result.
  • config.onAppend: A hook function append the custom item to the result list.
  • config.beforeNavigate: A hook function to before URL navigate. You have the last chance to modify the url before it navigated.
  • config.afterNavigate: A hook function to after URL navigated. You have the chance to record the history here.
  • config.onEmptyNavigate: If the content is a Non-URL which would navigate failed, then fallback to this hook function.

The onSearch, beforeNavigate, afterNavigated, and onEmptyNavigate in Omnibox::boostrap(config) can be async function.

addPrefixQueryEvent(prefix, event)

Add prefix query event.

addRegexQueryEvent(regex, event)

Add regex query event.

addNoCacheQueries(...queries)

Add query keyword to prevent cache result.

QueryEvent

{
    onSearch,
    onFormat = undefined,
    onAppend = undefined,
    prefix = undefined,
    regex = undefined,
    // Whether enable the query as a default search.
    // Default search means user can perform search without any sigils.
    defaultSearch = false,
    // The hook method to enable default search dynamically.
    // This hook method is preferred over defaultSearch property.
    isDefaultSearch = undefined,
    // The default search priority. The smaller, the higher.
    searchPriority = 0
}

The onSearch can be async function.

Command

An interface representing a command, you should extend this class to build a custom command.

constructor(name, description)

  • name: The command name, for example help.
  • description: The command description, for example Show the help messages.

onExecute(arg)

A hook method the subclass should implement to execute the command with the arg.

onBlankResult(arg)

A hook method when the command result is empty.

onEnter(content, disposition)

A hook method called when press enter on command directly.

CommandManager

constructor([prefix, ]commands)

Construct the CommandManager with default commands. The prefix for commands is configurable through prefix, which if not provided defaults to :.

execute(query)

Execute command according matched query.

handleCommandEnterEvent(content, disposition)

Handle command enter event.

Builtin commands

  • HistoryCommand - A command to record search histories.
  • SimpleCommand - A simple command to quick setup a list item of [name, url, description] data search.
  • OpenCommand - A command simply to quick open the specific url.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

search-extension-core's People

Contributors

chayleaf avatar folyd avatar light4 avatar pitkley avatar shwin0901 avatar yescallop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

search-extension-core's Issues

Evaluate necessity of `tabs` permission

For both manifests this repo currently defines the tabs permission as required:

_permissions:: [
'tabs',
],

_permissions:: [
'tabs',
],

I recently got an update to my extension rejected by the Chrome Web Store because they (correctly!) flagged the tabs permissions as unnecessary. As per the MV3 docs (and this also applies to MV2):

Gives your extension access to privileged fields of the Tab objects used by several APIs including chrome.tabs and chrome.windows. In many circumstances your extension will not need to declare the "tabs" permission to make use of these APIs.

I verified that none of the features the aws-search-extension uses requires these extended permissions and removed them in pitkley/aws-search-extension@f7ab2f1, after which the CWS approved my update.

I'm not sure if any of your or the other community extensions make use of the privileged tabs-APIs, but I still feel like the core manifest should not require that permission outright, requiring a workaround to remove it. WDYT?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.