mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-06-14 08:15:03 +12:00
enable ability to detach the logger (same as uBO)
This commit is contained in:
parent
6aa8c856cf
commit
0207c91312
|
@ -266,6 +266,12 @@ vAPI.tabs.open = function(details) {
|
|||
});
|
||||
};
|
||||
|
||||
// Open in a standalone window
|
||||
if ( details.popup === true ) {
|
||||
chrome.windows.create({ url: details.url, type: 'popup' });
|
||||
return;
|
||||
}
|
||||
|
||||
if ( details.index !== -1 ) {
|
||||
subWrapper();
|
||||
return;
|
||||
|
|
|
@ -86,6 +86,7 @@ return {
|
|||
onBeforeStartQueue: [],
|
||||
|
||||
userSettings: {
|
||||
alwaysDetachLogger: false,
|
||||
autoUpdate: false,
|
||||
clearBrowserCache: true,
|
||||
clearBrowserCacheAfter: 60,
|
||||
|
|
|
@ -74,11 +74,11 @@ function onMessage(request, sender, callback) {
|
|||
break;
|
||||
|
||||
case 'gotoExtensionURL':
|
||||
µm.utils.gotoExtensionURL(request.url);
|
||||
µm.gotoExtensionURL(request);
|
||||
break;
|
||||
|
||||
case 'gotoURL':
|
||||
µm.utils.gotoURL(request);
|
||||
µm.gotoURL(request);
|
||||
break;
|
||||
|
||||
case 'mustBlock':
|
||||
|
|
|
@ -1298,7 +1298,11 @@ function mouseleaveMatrixCellHandler() {
|
|||
function gotoExtensionURL(ev) {
|
||||
var url = uDom(ev.currentTarget).attr('data-extension-url');
|
||||
if ( url ) {
|
||||
messager.send({ what: 'gotoExtensionURL', url: url });
|
||||
messager.send({
|
||||
what: 'gotoExtensionURL',
|
||||
url: url,
|
||||
shiftKey: ev.shiftKey
|
||||
});
|
||||
}
|
||||
dropDownMenuHide();
|
||||
vAPI.closePopup();
|
||||
|
|
|
@ -97,14 +97,14 @@
|
|||
var out = new Set(),
|
||||
reIgnore = /^[!#]/,
|
||||
reValid = /^[a-z-]+:\/\/\S+/,
|
||||
lineIter = new this.utils.LineIterator(raw),
|
||||
lineIter = new this.LineIterator(raw),
|
||||
location;
|
||||
while ( lineIter.eot() === false ) {
|
||||
location = lineIter.next().trim();
|
||||
if ( reIgnore.test(location) || !reValid.test(location) ) { continue; }
|
||||
out.add(location);
|
||||
}
|
||||
return this.utils.setToArray(out);
|
||||
return this.setToArray(out);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -391,7 +391,7 @@
|
|||
title: assetKey
|
||||
};
|
||||
}
|
||||
externalHostsFiles = this.utils.setToArray(importedSet).sort().join('\n');
|
||||
externalHostsFiles = this.setToArray(importedSet).sort().join('\n');
|
||||
}
|
||||
|
||||
if ( externalHostsFiles !== this.userSettings.externalHostsFiles ) {
|
||||
|
|
102
src/js/utils.js
102
src/js/utils.js
|
@ -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
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -23,70 +23,70 @@
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
// This will inserted as a module in the µMatrix object.
|
||||
|
||||
µMatrix.utils = (function() {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var gotoURL = function(details) {
|
||||
µMatrix.gotoURL = function(details) {
|
||||
vAPI.tabs.open(details);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var gotoExtensionURL = function(url) {
|
||||
vAPI.tabs.open({
|
||||
url: url,
|
||||
index: -1,
|
||||
select: true
|
||||
});
|
||||
µMatrix.gotoExtensionURL = function(details) {
|
||||
if ( details.url.startsWith('logger-ui.html') ) {
|
||||
if ( details.shiftKey ) {
|
||||
this.changeUserSettings(
|
||||
'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.textLen = this.text.length;
|
||||
this.offset = offset || 0;
|
||||
};
|
||||
|
||||
LineIterator.prototype.next = function() {
|
||||
var lineEnd = this.text.indexOf('\n', this.offset);
|
||||
if ( lineEnd === -1 ) {
|
||||
lineEnd = this.text.indexOf('\r', this.offset);
|
||||
µMatrix.LineIterator.prototype = {
|
||||
next: function() {
|
||||
var lineEnd = this.text.indexOf('\n', this.offset);
|
||||
if ( lineEnd === -1 ) {
|
||||
lineEnd = this.textLen;
|
||||
lineEnd = this.text.indexOf('\r', this.offset);
|
||||
if ( lineEnd === -1 ) {
|
||||
lineEnd = this.textLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
var line = this.text.slice(this.offset, lineEnd);
|
||||
this.offset = lineEnd + 1;
|
||||
return line;
|
||||
};
|
||||
|
||||
LineIterator.prototype.rewind = function() {
|
||||
if ( this.offset <= 1 ) {
|
||||
this.offset = 0;
|
||||
return;
|
||||
}
|
||||
var lineEnd = this.text.lastIndexOf('\n', this.offset - 2);
|
||||
if ( lineEnd !== -1 ) {
|
||||
var line = this.text.slice(this.offset, lineEnd);
|
||||
this.offset = lineEnd + 1;
|
||||
} else {
|
||||
lineEnd = this.text.lastIndexOf('\r', this.offset - 2);
|
||||
this.offset = lineEnd !== -1 ? lineEnd + 1 : 0;
|
||||
return line;
|
||||
},
|
||||
rewind: function() {
|
||||
if ( this.offset <= 1 ) {
|
||||
this.offset = 0;
|
||||
return;
|
||||
}
|
||||
var lineEnd = this.text.lastIndexOf('\n', this.offset - 2);
|
||||
if ( lineEnd !== -1 ) {
|
||||
this.offset = lineEnd + 1;
|
||||
} else {
|
||||
lineEnd = this.text.lastIndexOf('\r', this.offset - 2);
|
||||
this.offset = lineEnd !== -1 ? lineEnd + 1 : 0;
|
||||
}
|
||||
},
|
||||
eot: function() {
|
||||
return this.offset >= this.textLen;
|
||||
}
|
||||
};
|
||||
|
||||
LineIterator.prototype.eot = function() {
|
||||
return this.offset >= this.textLen;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var setToArray = typeof Array.from === 'function'
|
||||
? Array.from
|
||||
: function(dict) {
|
||||
µMatrix.setToArray = typeof Array.from === 'function' ?
|
||||
Array.from :
|
||||
function(dict) {
|
||||
var out = [],
|
||||
entries = dict.values(),
|
||||
entry;
|
||||
|
@ -98,22 +98,8 @@ var setToArray = typeof Array.from === 'function'
|
|||
return out;
|
||||
};
|
||||
|
||||
var setFromArray = function(arr) {
|
||||
µMatrix.setFromArray = function(arr) {
|
||||
return new Set(arr);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
return {
|
||||
gotoURL: gotoURL,
|
||||
gotoExtensionURL: gotoExtensionURL,
|
||||
LineIterator: LineIterator,
|
||||
setToArray: setToArray,
|
||||
setFromArray: setFromArray
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
})();
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
Loading…
Reference in a new issue