Skip to content

skyh/contexta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contexta

DOM regex-based advertisement script

Usage

var contexta = new Contexta(config);

// activate on element1 and all it's child elements
contexta.activate(element1);

// activate on element2 and all it's child elements
contexta.activate(element2);

Contexta can be activated or deactivated on any element

contexta.activate(document.body);
Contexta.deactivateAll(document.body);

Config

{
	endpoint: 'http://example.org?search=%text',
	dict: [
		'квант\\W*?(?=$|[^а-яА-Я0-9\\-])', 
		'взрыв\\W*?'
	]
}

%text in endpoint will be replaced to matched text dict must be array of RegExp or String objects, any string will be internally converted to RegExp with this function

function stringToRx(s) {
	return new RegExp(s, 'igm');
}

About

DOM regex-based advertisement script

Resources

Stars

Watchers

Forks

Packages

No packages published