mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-03 17:49:39 +02:00
this fixes #227
This commit is contained in:
parent
284b4f62d1
commit
43f9657d0f
@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
|
||||||
"name": "uBlock Origin",
|
"name": "uBlock Origin",
|
||||||
"version": "0.9.6.0",
|
"version": "0.9.7.5",
|
||||||
|
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"description": "__MSG_extShortDesc__",
|
"description": "__MSG_extShortDesc__",
|
||||||
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"19": "img/browsericons/icon19-off.png",
|
"19": "img/browsericons/icon19.png",
|
||||||
"38": "img/browsericons/icon38-off.png"
|
"38": "img/browsericons/icon19.png"
|
||||||
},
|
},
|
||||||
"default_title": "uBlock Origin",
|
"default_title": "uBlock Origin",
|
||||||
"default_popup": "popup.html"
|
"default_popup": "popup.html"
|
||||||
|
@ -277,6 +277,7 @@ body[dir="rtl"] #popupContainer > div {
|
|||||||
#urlFilteringMenu .dialog {
|
#urlFilteringMenu .dialog {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
|
max-width: 70%;
|
||||||
padding: 0.2em;
|
padding: 0.2em;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
@ -310,7 +311,6 @@ body.dirty #urlFilteringMenu .save {
|
|||||||
#urlFilteringMenu .entries {
|
#urlFilteringMenu .entries {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
max-height: 12em;
|
max-height: 12em;
|
||||||
max-width: 70vw;
|
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
#urlFilteringMenu .entries > div {
|
#urlFilteringMenu .entries > div {
|
||||||
|
@ -645,6 +645,8 @@ var urlFilteringMenu = (function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var persist = !!ev.ctrlKey || !!ev.metaKey;
|
||||||
|
|
||||||
// Remove url filtering rule
|
// Remove url filtering rule
|
||||||
if ( target.classList.contains('action') ) {
|
if ( target.classList.contains('action') ) {
|
||||||
messager.send({
|
messager.send({
|
||||||
@ -652,7 +654,8 @@ var urlFilteringMenu = (function() {
|
|||||||
context: selectContext.value,
|
context: selectContext.value,
|
||||||
url: target.getAttribute('data-url'),
|
url: target.getAttribute('data-url'),
|
||||||
type: uglyTypeFromSelector(),
|
type: uglyTypeFromSelector(),
|
||||||
action: 0
|
action: 0,
|
||||||
|
persist: persist
|
||||||
}, colorize);
|
}, colorize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -664,7 +667,8 @@ var urlFilteringMenu = (function() {
|
|||||||
context: selectContext.value,
|
context: selectContext.value,
|
||||||
url: target.parentNode.getAttribute('data-url'),
|
url: target.parentNode.getAttribute('data-url'),
|
||||||
type: uglyTypeFromSelector(),
|
type: uglyTypeFromSelector(),
|
||||||
action: 2
|
action: 2,
|
||||||
|
persist: persist
|
||||||
}, colorize);
|
}, colorize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -676,7 +680,8 @@ var urlFilteringMenu = (function() {
|
|||||||
context: selectContext.value,
|
context: selectContext.value,
|
||||||
url: target.parentNode.getAttribute('data-url'),
|
url: target.parentNode.getAttribute('data-url'),
|
||||||
type: uglyTypeFromSelector(),
|
type: uglyTypeFromSelector(),
|
||||||
action: 3
|
action: 3,
|
||||||
|
persist: persist
|
||||||
}, colorize);
|
}, colorize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -688,7 +693,8 @@ var urlFilteringMenu = (function() {
|
|||||||
context: selectContext.value,
|
context: selectContext.value,
|
||||||
url: target.parentNode.getAttribute('data-url'),
|
url: target.parentNode.getAttribute('data-url'),
|
||||||
type: uglyTypeFromSelector(),
|
type: uglyTypeFromSelector(),
|
||||||
action: 1
|
action: 1,
|
||||||
|
persist: persist
|
||||||
}, colorize);
|
}, colorize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1212,35 +1212,6 @@ var getURLFilteringData = function(details) {
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var saveTemporaryURLFilteringRules = function(details) {
|
|
||||||
var changed = false;
|
|
||||||
var suf = µb.sessionURLFiltering;
|
|
||||||
var puf = µb.permanentURLFiltering;
|
|
||||||
var urls = details.urls,
|
|
||||||
context = details.context,
|
|
||||||
type = details.type;
|
|
||||||
var url, sOwn, pOwn;
|
|
||||||
var i = urls.length;
|
|
||||||
while ( i-- ) {
|
|
||||||
url = urls[i];
|
|
||||||
suf.evaluateZ(context, url, type);
|
|
||||||
sOwn = suf.context === context && suf.url === url && suf.type === type;
|
|
||||||
puf.evaluateZ(context, url, type);
|
|
||||||
pOwn = puf.context === context && puf.url === url && puf.type === type;
|
|
||||||
if ( sOwn && !pOwn ) {
|
|
||||||
puf.setRule(context, url, type, suf.r);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if ( !sOwn && pOwn ) {
|
|
||||||
puf.removeRule(context, url, type);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed;
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
var onMessage = function(request, sender, callback) {
|
var onMessage = function(request, sender, callback) {
|
||||||
// Async
|
// Async
|
||||||
switch ( request.what ) {
|
switch ( request.what ) {
|
||||||
@ -1276,7 +1247,13 @@ var onMessage = function(request, sender, callback) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'saveURLFilteringRules':
|
case 'saveURLFilteringRules':
|
||||||
if ( saveTemporaryURLFilteringRules(request) ) {
|
response = µb.permanentURLFiltering.copyRules(
|
||||||
|
µb.sessionURLFiltering,
|
||||||
|
request.context,
|
||||||
|
request.urls,
|
||||||
|
request.type
|
||||||
|
);
|
||||||
|
if ( response ) {
|
||||||
µb.savePermanentURLFilteringRules();
|
µb.savePermanentURLFilteringRules();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -325,6 +325,21 @@ var matchWhitelistDirective = function(url, hostname, directive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.cosmeticFilteringEngine.removeFromSelectorCache(details.context, 'net');
|
this.cosmeticFilteringEngine.removeFromSelectorCache(details.context, 'net');
|
||||||
|
|
||||||
|
if ( !details.persist ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
changed = this.permanentURLFiltering.setRule(
|
||||||
|
details.context,
|
||||||
|
details.url,
|
||||||
|
details.type,
|
||||||
|
details.action
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( changed ) {
|
||||||
|
this.savePermanentFirewallRules();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
buckets: map of [origin + urlkey]
|
buckets: map of [origin + urlkey + type]
|
||||||
bucket: array of rule entry, sorted from shorter to longer url
|
bucket: array of rule entry, sorted from shorter to longer url
|
||||||
|
|
||||||
rule entry: { url, action }
|
rule entry: { url, action }
|
||||||
@ -127,6 +127,10 @@ var addRuleEntry = function(urls, url, action) {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var urlKeyFromURL = function(url) {
|
var urlKeyFromURL = function(url) {
|
||||||
|
// Experimental: running benchmarks first
|
||||||
|
//if ( url === '*' ) {
|
||||||
|
// return url;
|
||||||
|
//}
|
||||||
var match = reURLKey.exec(url);
|
var match = reURLKey.exec(url);
|
||||||
return match !== null ? match[0] : '';
|
return match !== null ? match[0] : '';
|
||||||
};
|
};
|
||||||
@ -142,7 +146,7 @@ var URLNetFiltering = function() {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// rules:
|
// rules:
|
||||||
// hostname + urlkey => urls
|
// origin + urlkey + type => urls
|
||||||
// urls = collection of urls to match
|
// urls = collection of urls to match
|
||||||
|
|
||||||
URLNetFiltering.prototype.reset = function() {
|
URLNetFiltering.prototype.reset = function() {
|
||||||
@ -243,12 +247,12 @@ URLNetFiltering.prototype.evaluateZ = function(context, target, type) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
var urls, pos, i, entry, prefixKey;
|
var urls, pos, i, entry, keyShard;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
prefixKey = context + ' ' + urlKey;
|
keyShard = context + ' ' + urlKey;
|
||||||
if ( urls = this.rules[prefixKey + ' ' + type] ) {
|
if ( urls = this.rules[keyShard + ' ' + type] ) {
|
||||||
i = indexOfMatch(urls, target);
|
i = indexOfMatch(urls, target);
|
||||||
if ( i !== -1 ) {
|
if ( i !== -1 ) {
|
||||||
entry = urls[i];
|
entry = urls[i];
|
||||||
@ -258,7 +262,7 @@ URLNetFiltering.prototype.evaluateZ = function(context, target, type) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( urls = this.rules[prefixKey + ' *'] ) {
|
if ( urls = this.rules[keyShard + ' *'] ) {
|
||||||
i = indexOfMatch(urls, target);
|
i = indexOfMatch(urls, target);
|
||||||
if ( i !== -1 ) {
|
if ( i !== -1 ) {
|
||||||
entry = urls[i];
|
entry = urls[i];
|
||||||
@ -268,6 +272,21 @@ URLNetFiltering.prototype.evaluateZ = function(context, target, type) {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Experimental: running benchmarks first
|
||||||
|
if ( urls = this.rules[context + ' * ' + type] ) {
|
||||||
|
entry = urls[0];
|
||||||
|
this.url = '*';
|
||||||
|
this.type = type;
|
||||||
|
this.r = entry.action;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if ( urls = this.rules[context + ' * *'] ) {
|
||||||
|
entry = urls[0];
|
||||||
|
this.url = this.type = '*';
|
||||||
|
this.r = entry.action;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
*/
|
||||||
if ( context === '*' ) {
|
if ( context === '*' ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -304,6 +323,30 @@ URLNetFiltering.prototype.toFilterString = function() {
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
URLNetFiltering.prototype.copyRules = function(other, context, urls, type) {
|
||||||
|
var changed = false;
|
||||||
|
var url, otherOwn, thisOwn;
|
||||||
|
var i = urls.length;
|
||||||
|
while ( i-- ) {
|
||||||
|
url = urls[i];
|
||||||
|
other.evaluateZ(context, url, type);
|
||||||
|
otherOwn = other.context === context && other.url === url && other.type === type;
|
||||||
|
this.evaluateZ(context, url, type);
|
||||||
|
thisOwn = this.context === context && this.url === url && this.type === type;
|
||||||
|
if ( otherOwn && !thisOwn ) {
|
||||||
|
this.setRule(context, url, type, other.r);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if ( !otherOwn && thisOwn ) {
|
||||||
|
this.removeRule(context, url, type);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
// "url-filtering:" hostname url action
|
// "url-filtering:" hostname url action
|
||||||
|
|
||||||
URLNetFiltering.prototype.toString = function() {
|
URLNetFiltering.prototype.toString = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user