🚀 Metasearch Tampermonkey
Customizable, themeable, mobile-friendly search engine aggregator script for Tampermonkey.
🌟 Features
- Displays a bar at the bottom of search engine result pages with buttons for searching on different engines.
- Buttons are customizable and can be reordered.
- Mobile-friendly, responsive design.
- Dark mode support with automatic theme detection.
- Optional deep linking for opening URLs in native apps on mobile.
- Flexible URL matching system, allowing strings, regular expressions, or custom functions.
- Powerful query parameter extraction logic for each search engine.
- Fast, lightweight, and dependency-free.
🚀 Usage
Install the Tampermonkey browser extension, then click one of the links below to install the script:
Currently, the script supports the following search engines:
💻 Development
Prerequisites
Clone the repository and install the dependencies:
git clone https://github.com/Jkker/metasearch-tampermonkey.git
cd metasearch-tampermonkey
pnpm install
Building
To build the script, run the following command:
pnpm run build
The build process is configured in vite.config.ts
. It includes two plugins: libInjectCss
for CSS injection and prependUserScriptHeader
for prepending a UserScript header.
🎨 Customization
Open src/config.ts
and edit the config
object to your liking. The config
object is a map of search engine names to search engine objects. Each search engine object has the following properties:
📝 Engine
Properties
name
: string
The name
property represents the name of the engine.
url
: string
The url
property specifies the URL associated with the engine.
deeplink?
: string (optional)
The deeplink
property is an optional URL scheme for opening the engine URL in native apps on mobile. If omitted, the url
property is used instead.
matcher?
: string | RegExp | ((url: string, query: URLSearchParams) => boolean) (optional)
The matcher
property determines how the current URL matches the engine. It can be of type string
, RegExp
, or a function
. The undefined
value implies that the engine is skipped during matching. By default, it is undefined
.
Variants:
string
: Matches if the URL contains the specified string.
RegExp
: Checks if the URL matches the regular expression.
function
: Returns true
if the URL matches the function's criteria.
q?
: string | string[] | RegExp | ((url: string, query: URLSearchParams) => string) (optional)
The q
property represents the query parameter used for searching. It can be a string
, string[]
, RegExp
, or a function
. By default, it is set to 'q'
.
Variants:
string
: The query parameter is used as the search query.
string[]
: The first found query parameter is used as the search query.
RegExp
: The first matching query parameter is used.
function
: Calls the function with URL and query parameters, using the return value as the search query.
key
: string
The key
property is a unique ASCII string for identifying the engine and for keyboard shortcuts.
icon
: string
The icon
property defines the icon for the engine.
color
: string
The color
property specifies the foreground color for the engine.
background?
: string (optional)
The background
property, optional, defines the engine's background color.
lightness?
: number (optional)
The lightness
property, optional, determines the lightness of the engine, affecting the text color (dark or light). The default value is 0.5
or computed from the color
property.
priority
: number
The priority
property signifies the engine's display priority. Higher values result in earlier display in lists. The default value is calculated as index * 0.1
.
disabled?
: boolean (optional)
The disabled
property, if set to true
, hides the engine from the list. By default, it is false
.
📖 Engine
Example
Below is an example of how to use the Engine
interface:
const searchEngine: Engine = {
name: 'ExampleEngine',
url: 'https://example.com',
deeplink: 'example://search',
matcher: (url) => url.includes('example.com'),
q: 'query',
key: 'example',
icon: '<svg>...</svg>',
color: '#FF5733',
background: '#FFFFFF',
lightness: 0.7,
priority: 2,
disabled: false,
};
🤝 Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
📜 License
MIT