mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-07-03 05:20:54 +12:00
importing rp rules
This commit is contained in:
parent
3d3160efdf
commit
257334b4c2
|
@ -95,14 +95,29 @@ var processUserRules = function(response) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var fromRequestPolicy = function(content) {
|
||||||
|
// https://github.com/chrisaljoudi/uBlock/issues/757
|
||||||
|
// Support RequestPolicy rule syntax
|
||||||
|
var matches = /\[origins-to-destinations\]([^\[]+)/.exec(content);
|
||||||
|
if ( matches === null || matches.length !== 2 ) {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
return matches[1].trim()
|
||||||
|
.replace(/\|/g, ' ')
|
||||||
|
.replace(/\n/g, ' * allow\n');
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
function handleImportFilePicker() {
|
function handleImportFilePicker() {
|
||||||
var fileReaderOnLoadHandler = function() {
|
var fileReaderOnLoadHandler = function() {
|
||||||
if ( typeof this.result !== 'string' || this.result === '' ) {
|
if ( typeof this.result !== 'string' || this.result === '' ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var result = fromRequestPolicy(this.result);
|
||||||
var request = {
|
var request = {
|
||||||
'what': 'setUserRules',
|
'what': 'setUserRules',
|
||||||
'temporaryRules': rulesFromHTML('#diff .right li') + '\n' + this.result
|
'temporaryRules': rulesFromHTML('#diff .right li') + '\n' + result
|
||||||
};
|
};
|
||||||
messager.send(request, processUserRules);
|
messager.send(request, processUserRules);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue