1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 10:09:38 +02:00
This commit is contained in:
gorhill 2016-09-27 08:31:12 -04:00
parent 42938c9b63
commit 7984c7562c
4 changed files with 16 additions and 41 deletions

View File

@ -473,11 +473,6 @@ body.portrait #firewallContainer > div > span:nth-of-type(4) {
#actionSelector.colorBlind > span:nth-of-type(3) {
background-color: rgb(0, 19, 110);
}
#firewallContainer span.aRule #actionSelector > span:nth-of-type(1),
#firewallContainer span.nRule #actionSelector > span:nth-of-type(2),
#firewallContainer span.bRule #actionSelector > span:nth-of-type(3) {
visibility: hidden;
}
#rulesetTools {
background-color: transparent;

View File

@ -1,7 +1,7 @@
/*******************************************************************************
uBlock - a browser extension to block requests.
Copyright (C) 2014 Raymond Hill
uBlock Origin - a browser extension to block requests.
Copyright (C) 2014-2016 Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -19,15 +19,15 @@
Home: https://github.com/gorhill/uBlock
*/
/* global punycode, µBlock */
/* global punycode */
/* jshint bitwise: false */
'use strict';
/******************************************************************************/
µBlock.Firewall = (function() {
'use strict';
/******************************************************************************/
var magicId = 'chmdgxwtetgu';
@ -94,6 +94,10 @@ var isIPAddress = function(hostname) {
/******************************************************************************/
// TODO: Rearrange the code so as to avoid calling isIPAddress() from within
// toBroaderHostname(). A hostname will never magically become an IP address
// when broadened -- so no need to test for this condition each call.
var toBroaderHostname = function(hostname) {
if ( isIPAddress(hostname) ) {
return '*';
@ -261,38 +265,10 @@ Matrix.prototype.unsetCell = function(srcHostname, desHostname, type) {
return true;
};
/******************************************************************************/
Matrix.prototype.setCellZ = function(srcHostname, desHostname, type, action) {
this.evaluateCellZY(srcHostname, desHostname, type);
if ( this.r === action ) {
return false;
}
this.setCell(srcHostname, desHostname, type, 0);
this.evaluateCellZY(srcHostname, desHostname, type);
if ( this.r === action ) {
return true;
}
this.setCell(srcHostname, desHostname, type, action);
return true;
};
/******************************************************************************/
Matrix.prototype.blockCell = function(srcHostname, desHostname, type) {
return this.setCellZ(srcHostname, desHostname, type, 1);
};
// https://www.youtube.com/watch?v=Csewb_eIStY
/******************************************************************************/
Matrix.prototype.allowCell = function(srcHostname, desHostname, type) {
return this.setCellZ(srcHostname, desHostname, type, 2);
};
/******************************************************************************/
Matrix.prototype.evaluateCell = function(srcHostname, desHostname, type) {
var key = srcHostname + ' ' + desHostname;
var bitmap = this.rules[key];

View File

@ -239,7 +239,7 @@ var updateFirewallCell = function(scope, des, type, rule) {
cell.toggleClass(action + 'Rule', true);
}
// Use dark shade visual cue if the filter is specific to the cell.
// Use dark shade visual cue if the rule is specific to the cell.
var ownRule = false;
var matches = reSrcHostnameFromRule.exec(rule);
if ( matches !== null ) {

View File

@ -330,11 +330,15 @@ var matchWhitelistDirective = function(url, hostname, directive) {
/******************************************************************************/
// https://github.com/gorhill/uBlock/issues/2033
// Always set own rules, trying to be fancy to avoid setting seemingly
// (but not really) redundant rules led to this issue.
µBlock.toggleFirewallRule = function(details) {
var requestType = details.requestType;
if ( details.action !== 0 ) {
this.sessionFirewall.setCellZ(details.srcHostname, details.desHostname, requestType, details.action);
this.sessionFirewall.setCell(details.srcHostname, details.desHostname, requestType, details.action);
} else {
this.sessionFirewall.unsetCell(details.srcHostname, details.desHostname, requestType);
}
@ -342,7 +346,7 @@ var matchWhitelistDirective = function(url, hostname, directive) {
// https://github.com/chrisaljoudi/uBlock/issues/731#issuecomment-73937469
if ( details.persist ) {
if ( details.action !== 0 ) {
this.permanentFirewall.setCellZ(details.srcHostname, details.desHostname, requestType, details.action);
this.permanentFirewall.setCell(details.srcHostname, details.desHostname, requestType, details.action);
} else {
this.permanentFirewall.unsetCell(details.srcHostname, details.desHostname, requestType, details.action);
}