|
|
@ -1,6 +1,6 @@
|
|
|
|
/*******************************************************************************
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix - a Chromium browser extension to black/white list requests.
|
|
|
|
uMatrix - a Chromium browser extension to black/white list requests.
|
|
|
|
Copyright (C) 2014-2017 Raymond Hill
|
|
|
|
Copyright (C) 2014-2017 Raymond Hill
|
|
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
@ -23,35 +23,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
// This will inserted as a module in the µMatrix object.
|
|
|
|
µMatrix.gotoURL = function(details) {
|
|
|
|
|
|
|
|
|
|
|
|
µMatrix.utils = (function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var gotoURL = function(details) {
|
|
|
|
|
|
|
|
vAPI.tabs.open(details);
|
|
|
|
vAPI.tabs.open(details);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
var gotoExtensionURL = function(url) {
|
|
|
|
µMatrix.gotoExtensionURL = function(details) {
|
|
|
|
vAPI.tabs.open({
|
|
|
|
if ( details.url.startsWith('logger-ui.html') ) {
|
|
|
|
url: url,
|
|
|
|
if ( details.shiftKey ) {
|
|
|
|
index: -1,
|
|
|
|
this.changeUserSettings(
|
|
|
|
select: true
|
|
|
|
'alwaysDetachLogger',
|
|
|
|
});
|
|
|
|
!this.userSettings.alwaysDetachLogger
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
details.popup = this.userSettings.alwaysDetachLogger;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
details.select = true;
|
|
|
|
|
|
|
|
vAPI.tabs.open(details);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
var LineIterator = function(text, offset) {
|
|
|
|
µMatrix.LineIterator = function(text, offset) {
|
|
|
|
this.text = text;
|
|
|
|
this.text = text;
|
|
|
|
this.textLen = this.text.length;
|
|
|
|
this.textLen = this.text.length;
|
|
|
|
this.offset = offset || 0;
|
|
|
|
this.offset = offset || 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
LineIterator.prototype.next = function() {
|
|
|
|
µMatrix.LineIterator.prototype = {
|
|
|
|
|
|
|
|
next: function() {
|
|
|
|
var lineEnd = this.text.indexOf('\n', this.offset);
|
|
|
|
var lineEnd = this.text.indexOf('\n', this.offset);
|
|
|
|
if ( lineEnd === -1 ) {
|
|
|
|
if ( lineEnd === -1 ) {
|
|
|
|
lineEnd = this.text.indexOf('\r', this.offset);
|
|
|
|
lineEnd = this.text.indexOf('\r', this.offset);
|
|
|
@ -62,9 +63,8 @@ LineIterator.prototype.next = function() {
|
|
|
|
var line = this.text.slice(this.offset, lineEnd);
|
|
|
|
var line = this.text.slice(this.offset, lineEnd);
|
|
|
|
this.offset = lineEnd + 1;
|
|
|
|
this.offset = lineEnd + 1;
|
|
|
|
return line;
|
|
|
|
return line;
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
rewind: function() {
|
|
|
|
LineIterator.prototype.rewind = function() {
|
|
|
|
|
|
|
|
if ( this.offset <= 1 ) {
|
|
|
|
if ( this.offset <= 1 ) {
|
|
|
|
this.offset = 0;
|
|
|
|
this.offset = 0;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -76,17 +76,17 @@ LineIterator.prototype.rewind = function() {
|
|
|
|
lineEnd = this.text.lastIndexOf('\r', this.offset - 2);
|
|
|
|
lineEnd = this.text.lastIndexOf('\r', this.offset - 2);
|
|
|
|
this.offset = lineEnd !== -1 ? lineEnd + 1 : 0;
|
|
|
|
this.offset = lineEnd !== -1 ? lineEnd + 1 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
eot: function() {
|
|
|
|
LineIterator.prototype.eot = function() {
|
|
|
|
|
|
|
|
return this.offset >= this.textLen;
|
|
|
|
return this.offset >= this.textLen;
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
var setToArray = typeof Array.from === 'function'
|
|
|
|
µMatrix.setToArray = typeof Array.from === 'function' ?
|
|
|
|
? Array.from
|
|
|
|
Array.from :
|
|
|
|
: function(dict) {
|
|
|
|
function(dict) {
|
|
|
|
var out = [],
|
|
|
|
var out = [],
|
|
|
|
entries = dict.values(),
|
|
|
|
entries = dict.values(),
|
|
|
|
entry;
|
|
|
|
entry;
|
|
|
@ -98,22 +98,8 @@ var setToArray = typeof Array.from === 'function'
|
|
|
|
return out;
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var setFromArray = function(arr) {
|
|
|
|
µMatrix.setFromArray = function(arr) {
|
|
|
|
return new Set(arr);
|
|
|
|
return new Set(arr);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
gotoURL: gotoURL,
|
|
|
|
|
|
|
|
gotoExtensionURL: gotoExtensionURL,
|
|
|
|
|
|
|
|
LineIterator: LineIterator,
|
|
|
|
|
|
|
|
setToArray: setToArray,
|
|
|
|
|
|
|
|
setFromArray: setFromArray
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|