0.0.0 • Published 5 years ago
webext-pattern-to-regex v0.0.0
webext-pattern-to-regex 
Tool to convert the patterns of your WebExtension manifest to regex
This might be incomplete. Please help me test it.
Install
You can just download the standalone bundle (it might take a minute to download) and include the file in your manifest.json
, or:
npm install webext-pattern-to-regex
// This module is only offered as a ES Module
import webextPatternToRegex from 'webext-pattern-to-regex';
Usage
webextPatternToRegex('http://*/*');
// Returns /^http:\/\/?.+\/.+$/
const gmailRegex = webextPatternToRegex('*://mail.google.com/*');
gmailRegex.test('https://mail.google.com/a/b/c'); // -> true
gmailRegex.test('https://photos.google.com/a/b/c'); // -> false
// Also accepts an array of patterns and returns a single regex
const googleRegex = webextPatternToRegex(
'https://google.com/*',
'https://google.it/*'
);
googleRegex.test('https://google.it/search'); // -> true
googleRegex.test('https://google.de/search'); // -> false
API
webextPatternToRegex(pattern1, pattern2, etc)
Accepts any number of string
arguments and returns a single regex to match all of them.
Related
Permissions
- webext-additional-permissions - Get any optional permissions that users have granted you.
- webext-dynamic-content-scripts - Automatically registers your content_scripts on domains added via permission.request
- webext-permissions-events-polyfill - Polyfill for
onAdded
andonRemoved
permission events for Firefox. (included inwebext-dynamic-content-scripts
)
Others
- webext-options-sync - Helps you manage and autosave your extension's options. Chrome and Firefox.
- webext-storage-cache - Map-like promised cache storage with expiration. Chrome and Firefox
- webext-detect-page - Detects where the current browser extension code is being run. Chrome and Firefox.
- webext-content-script-ping - One-file interface to detect whether your content script have loaded.
- web-ext-submit - Wrapper around Mozilla’s web-ext to submit extensions to AMO.
- Awesome-WebExtensions - A curated list of awesome resources for WebExtensions development.
License
MIT © Federico Brigante
0.0.0
5 years ago