Skip to content

A Javascript library that manages mach patterns for matching urls

License

Notifications You must be signed in to change notification settings

jc3213/matchpattern.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

Usage

Download

Latest

HTML

<script src="https://jc3213.github.io/matchpattern.js/matchpattern.js"></script>

TamperMonkey

// @require https://jc3213.github.io/matchpattern.js/matchpattern.js

Syntax

let match = new MatchPattern();
match.proxy = 'SOCKS 127.0.0.1:1080';

Method

add

match.add("www.example.com"); // *.example.com

remove

match.remove('*.example.com');

clear

match.clear();

make

let result = MatchPattern.make('www.microsoft.com'); // *.microsoft.com

merge

let merged = MatchPattern.merge();
let regexp = merged.regexp;
let pac_script = merged.pac_script;

erase

MatchPattern.erase('SOCKS 127.0.0.1:1080');
MatchPattern.erase('SOCKS 127.0.0.1:1080', 'HTTPS 127.0.0.1:6780');
MatchPattern.erase( ['SOCKS 127.0.0.1:1080', 'HTTPS 127.0.0.1:6780'] );

MatchPattern

  • *.example.com
    • Matches www.example.com, example.com
    • Doesn't Match test-example.com, www.example.com.cn
  • example.*
    • Matches example.com, example.co.uk
    • Doesen't Match www.example.com, example-test.com
Match Pattern Target Hostname
<all-urls> All hostnames
www.university.org.eu
*.university.org.eu
*.org.eu
www.university.org.eu
doc.university.org.eu
doc.university.org.*
doc.university.*
doc.university.org.eu
192.168.1.*
192.168.*
192.*
192.168.1.1