
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
This library allows users to mark page content fragments and get unique url to the page with marked fragments. Anybody can select chosen parts (paragraphs, sentences or words) and share these selection with others. Opening of that url will open the page with same content and restored marks.
This feature was developed for official site of President of Russia. After some months of active use it was published under MIT license.
MASHA has been written in clean JavaScript and does not have any framework dependencies (except bundled ierange library that included to support Internet Explorer browser).
To enable MASHA on your page you need to add inside <head/> tag that code:
<!--[IF IE]>
<script type="text/javascript" src="ierange.js"></script>
<![ENDIF]-->
<script type="text/javascript" src="masha.js"></script>
<link rel="stylesheet" type="text/css" href="masha.css">
<script type="text/javascript">
// if jQuery is not available
if (window.addEventListener) {
window.addEventListener('load', function() {
// can be called by domready
MaSha.instance = new MaSha();
}, false);
} else {
window.attachEvent('onload', function() {
// can be called by domready
MaSha.instance = new MaSha();
});
}
// if jQuery available:
$(document).ready(function() {
MaSha.instance = new MaSha();
});
</script>
MASHA uses three elements on the page:
All options are defined by default, but you can override any of them on Masha object instance creation.
new MaSha({ option: 'value' })
{
'regexp': '[^\\s,;:–.!?<>…\\n\xA0\\*]+',
'selectable': 'selectable-content',
'marker': 'txtselect_marker',
'ignored': null,
'selectMessage': null,
'location': new LocationHandler(),
'validate': false,
'enableHaschange': true,
'onMark': null,
'onUnmark': null,
'onHashRead': function(){ … }
}
where
MASHA uses custom bundled variant of ierange script to support Internet Explorer.
If you use mainstream ierange library instead of bundled one please add this line to end of root function:
window.DOMRange = DOMRange;
MaSha supports pages with multiple text blocks, including forum threads. In this case, for each text block own MaSha instance is created, and each text block has separate paragraph and text numeration. This behavior is implemented by MultiMasha, a constructor accepting three parameters:
Example of usage:
var posts = document.querySelectorAll('.post-text');
new MultiMaSha(posts, function(element){
return element.id.split('-')[1];
}, {
'validate': true
});
FAQs
JS tool for mark and share text parts
The npm package masha receives a total of 3 weekly downloads. As such, masha popularity was classified as not popular.
We found that masha demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.