2014-06-24 00:42:43 +02:00
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
2015-03-07 19:20:18 +01:00
|
|
|
|
µBlock - a browser extension to block requests.
|
2014-06-24 00:42:43 +02:00
|
|
|
|
Copyright (C) 2014 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
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see {http://www.gnu.org/licenses/}.
|
|
|
|
|
|
|
|
|
|
Home: https://github.com/gorhill/uBlock
|
|
|
|
|
*/
|
|
|
|
|
|
2014-10-17 21:44:19 +02:00
|
|
|
|
/* global vAPI, uDom */
|
2014-07-07 03:52:16 +02:00
|
|
|
|
|
2014-06-24 00:42:43 +02:00
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
|
2014-11-24 15:48:33 +01:00
|
|
|
|
'use strict';
|
|
|
|
|
|
2014-06-24 00:42:43 +02:00
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-01-06 14:01:15 +01:00
|
|
|
|
var popupData;
|
|
|
|
|
var dfPaneBuilt = false;
|
2014-12-30 22:36:29 +01:00
|
|
|
|
var popupHeight;
|
|
|
|
|
var reIP = /^\d+(?:\.\d+){1,3}$/;
|
2015-02-04 15:03:34 +01:00
|
|
|
|
var reSrcHostnameFromRule = /^d[abn]:([^ ]+) ([^ ]+) ([^ ]+)/;
|
2014-12-30 22:36:29 +01:00
|
|
|
|
var scopeToSrcHostnameMap = {
|
|
|
|
|
'/': '*',
|
|
|
|
|
'.': ''
|
|
|
|
|
};
|
|
|
|
|
var threePlus = '+++';
|
2014-12-31 16:47:19 +01:00
|
|
|
|
var threeMinus = '−−−';
|
2014-12-30 22:36:29 +01:00
|
|
|
|
var sixSpace = '\u2007\u2007\u2007\u2007\u2007\u2007';
|
2015-01-06 14:01:15 +01:00
|
|
|
|
var dfHotspots = null;
|
2014-12-31 23:26:17 +01:00
|
|
|
|
var hostnameToSortableTokenMap = {};
|
2015-01-07 01:51:50 +01:00
|
|
|
|
var allDomains = {};
|
|
|
|
|
var allDomainCount = 0;
|
2015-02-06 23:46:20 +01:00
|
|
|
|
var allHostnameRows = [];
|
2015-01-07 01:51:50 +01:00
|
|
|
|
var touchedDomainCount = 0;
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var rowsToRecycle = uDom();
|
|
|
|
|
var cachedPopupHash = '';
|
2015-02-06 23:42:09 +01:00
|
|
|
|
var orStr = vAPI.i18n('popupOr');
|
2015-02-07 00:20:33 +01:00
|
|
|
|
var domainsHitStr = vAPI.i18n('popupHitDomainCount');
|
2014-06-24 00:42:43 +02:00
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/345
|
|
|
|
|
|
2014-10-17 21:44:19 +02:00
|
|
|
|
var messager = vAPI.messaging.channel('popup.js');
|
|
|
|
|
|
2014-12-30 22:36:29 +01:00
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
var cachePopupData = function(data) {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
popupData = {};
|
2014-12-31 23:26:17 +01:00
|
|
|
|
scopeToSrcHostnameMap['.'] = '';
|
|
|
|
|
hostnameToSortableTokenMap = {};
|
2015-01-07 01:51:50 +01:00
|
|
|
|
|
2014-12-31 23:26:17 +01:00
|
|
|
|
if ( typeof data !== 'object' ) {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
return popupData;
|
2014-12-25 14:53:30 +01:00
|
|
|
|
}
|
2015-01-06 14:01:15 +01:00
|
|
|
|
popupData = data;
|
|
|
|
|
scopeToSrcHostnameMap['.'] = popupData.pageHostname || '';
|
|
|
|
|
var hostnameDict = popupData.hostnameDict;
|
2015-01-07 01:51:50 +01:00
|
|
|
|
if ( typeof hostnameDict !== 'object' ) {
|
|
|
|
|
return popupData;
|
|
|
|
|
}
|
|
|
|
|
var domain, prefix;
|
|
|
|
|
for ( var hostname in hostnameDict ) {
|
|
|
|
|
if ( hostnameDict.hasOwnProperty(hostname) === false ) {
|
|
|
|
|
continue;
|
2014-12-31 23:26:17 +01:00
|
|
|
|
}
|
2015-01-07 01:51:50 +01:00
|
|
|
|
domain = hostnameDict[hostname].domain;
|
|
|
|
|
if ( domain === popupData.pageDomain ) {
|
|
|
|
|
domain = '\u0020';
|
|
|
|
|
}
|
|
|
|
|
prefix = hostname.slice(0, 0 - domain.length);
|
|
|
|
|
hostnameToSortableTokenMap[hostname] = domain + prefix.split('.').reverse().join('.');
|
2014-12-30 22:36:29 +01:00
|
|
|
|
}
|
2015-01-06 14:01:15 +01:00
|
|
|
|
return popupData;
|
2014-12-30 22:36:29 +01:00
|
|
|
|
};
|
2014-06-24 00:42:43 +02:00
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var hashFromPopupData = function(reset) {
|
2015-01-24 18:06:22 +01:00
|
|
|
|
// It makes no sense to offer to refresh the behind-the-scene scope
|
|
|
|
|
if ( popupData.pageHostname === 'behind-the-scene' ) {
|
|
|
|
|
uDom('body').toggleClass('dirty', false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var hasher = [];
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var rules = popupData.firewallRules;
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var rule;
|
|
|
|
|
for ( var key in rules ) {
|
|
|
|
|
if ( rules.hasOwnProperty(key) === false ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
rule = rules[key];
|
|
|
|
|
if ( rule !== '' ) {
|
|
|
|
|
hasher.push(rule);
|
|
|
|
|
}
|
2014-06-24 07:20:59 +02:00
|
|
|
|
}
|
2015-02-09 21:24:24 +01:00
|
|
|
|
hasher.push(uDom('body').hasClass('off'));
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
|
|
|
|
var hash = hasher.sort().join('');
|
|
|
|
|
if ( reset ) {
|
|
|
|
|
cachedPopupHash = hash;
|
|
|
|
|
}
|
|
|
|
|
uDom('body').toggleClass('dirty', hash !== cachedPopupHash);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
var formatNumber = function(count) {
|
|
|
|
|
return typeof count === 'number' ? count.toLocaleString() : '';
|
2014-06-24 07:20:59 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2014-12-30 22:36:29 +01:00
|
|
|
|
var rulekeyCompare = function(a, b) {
|
|
|
|
|
var ha = a.slice(2, a.indexOf(' ', 2));
|
|
|
|
|
if ( !reIP.test(ha) ) {
|
2014-12-31 23:26:17 +01:00
|
|
|
|
ha = hostnameToSortableTokenMap[ha] || '';
|
2014-12-30 22:36:29 +01:00
|
|
|
|
}
|
|
|
|
|
var hb = b.slice(2, b.indexOf(' ', 2));
|
|
|
|
|
if ( !reIP.test(hb) ) {
|
2014-12-31 23:26:17 +01:00
|
|
|
|
hb = hostnameToSortableTokenMap[hb] || '';
|
2014-12-30 22:36:29 +01:00
|
|
|
|
}
|
|
|
|
|
return ha.localeCompare(hb);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var addFirewallRow = function(des) {
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var row = rowsToRecycle.pop();
|
|
|
|
|
if ( row.length === 0 ) {
|
|
|
|
|
row = uDom('#templates > div:nth-of-type(1)').clone();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-30 22:36:29 +01:00
|
|
|
|
row.descendants('[data-des]').attr('data-des', des);
|
2015-01-14 23:45:55 +01:00
|
|
|
|
row.descendants('span:nth-of-type(1)').text(punycode.toUnicode(des));
|
2014-12-30 22:36:29 +01:00
|
|
|
|
|
2015-01-06 14:01:15 +01:00
|
|
|
|
var hnDetails = popupData.hostnameDict[des] || {};
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
2015-02-17 03:15:09 +01:00
|
|
|
|
var isDomain = des === hnDetails.domain;
|
|
|
|
|
row.toggleClass('isDomain', isDomain);
|
|
|
|
|
row.toggleClass('isSubDomain', !isDomain);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
row.toggleClass('allowed', hnDetails.allowCount !== 0);
|
|
|
|
|
row.toggleClass('blocked', hnDetails.blockCount !== 0);
|
2015-02-11 06:26:45 +01:00
|
|
|
|
row.appendTo('#firewallContainer');
|
2014-12-30 22:36:29 +01:00
|
|
|
|
|
|
|
|
|
// Hacky? I couldn't figure a CSS recipe for this problem.
|
|
|
|
|
// I do not want the left pane -- optional and hidden by defaut -- to
|
2014-12-25 14:53:30 +01:00
|
|
|
|
// dictate the height of the popup. The right pane dictates the height
|
|
|
|
|
// of the popup, and the left pane will have a scrollbar if ever its
|
2014-12-30 22:36:29 +01:00
|
|
|
|
// height is larger than what is available.
|
|
|
|
|
if ( popupHeight === undefined ) {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
popupHeight = uDom('#panes > div:nth-of-type(1)').nodeAt(0).offsetHeight;
|
|
|
|
|
uDom('#panes > div:nth-of-type(2)').css('height', popupHeight + 'px');
|
2015-02-11 20:44:08 +01:00
|
|
|
|
|
|
|
|
|
// The padlock must be manually positioned:
|
|
|
|
|
// - It's vertical position depends on the height on the title bar.
|
|
|
|
|
var rect = document.getElementById('gotoPrefs').getBoundingClientRect();
|
|
|
|
|
document.getElementById('saveRules').style.setProperty('top', (rect.bottom + 4) + 'px');
|
2014-12-30 22:36:29 +01:00
|
|
|
|
}
|
|
|
|
|
return row;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var updateFirewallCell = function(scope, des, type, rule) {
|
|
|
|
|
var selector = '#firewallContainer span[data-src="' + scope + '"][data-des="' + des + '"][data-type="' + type + '"]';
|
2014-12-30 22:36:29 +01:00
|
|
|
|
var cell = uDom(selector);
|
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
// This should not happen
|
2014-12-30 22:36:29 +01:00
|
|
|
|
if ( cell.length === 0 ) {
|
2015-01-10 17:23:28 +01:00
|
|
|
|
return;
|
2014-12-30 22:36:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-31 16:47:19 +01:00
|
|
|
|
cell.removeClass();
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var action = rule.charAt(1);
|
2014-12-31 16:47:19 +01:00
|
|
|
|
if ( action !== '' ) {
|
|
|
|
|
cell.toggleClass(action + 'Rule', true);
|
|
|
|
|
}
|
2014-10-27 17:14:57 +01:00
|
|
|
|
|
2014-12-30 22:36:29 +01:00
|
|
|
|
// Use dark shade visual cue if the filter is specific to the cell.
|
2014-12-31 16:47:19 +01:00
|
|
|
|
var ownRule = false;
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var matches = reSrcHostnameFromRule.exec(rule);
|
2014-12-28 16:07:43 +01:00
|
|
|
|
if ( matches !== null ) {
|
2015-02-04 18:51:43 +01:00
|
|
|
|
ownRule = (matches[2] !== '*' || matches[3] === type) &&
|
|
|
|
|
(matches[2] === des) &&
|
|
|
|
|
(matches[1] === scopeToSrcHostnameMap[scope]);
|
2014-10-27 17:14:57 +01:00
|
|
|
|
}
|
2014-12-31 16:47:19 +01:00
|
|
|
|
cell.toggleClass('ownRule', ownRule);
|
2014-12-30 22:36:29 +01:00
|
|
|
|
|
2015-02-07 21:39:46 +01:00
|
|
|
|
if ( scope !== '.' || des === '*' ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-07 21:32:20 +01:00
|
|
|
|
// IMPORTANT: It is completely assumed the first node is a TEXT_NODE, so
|
|
|
|
|
// ensure this in the HTML file counterpart when you make
|
|
|
|
|
// changes
|
|
|
|
|
var textNode = cell.nodeAt(0).firstChild;
|
|
|
|
|
|
2015-02-07 21:39:46 +01:00
|
|
|
|
// Remember this may be a cell from a reused row, we need to clear text
|
2015-02-07 21:32:20 +01:00
|
|
|
|
// content if we can't compute request counts.
|
2015-02-07 21:39:46 +01:00
|
|
|
|
if ( popupData.hostnameDict.hasOwnProperty(des) === false ) {
|
2015-02-07 21:32:20 +01:00
|
|
|
|
textNode.nodeValue = ' ';
|
2014-12-30 22:36:29 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-02-07 21:32:20 +01:00
|
|
|
|
|
2015-01-06 14:01:15 +01:00
|
|
|
|
var hnDetails = popupData.hostnameDict[des];
|
2015-01-01 13:29:28 +01:00
|
|
|
|
var aCount = hnDetails.allowCount;
|
|
|
|
|
var bCount = hnDetails.blockCount;
|
2015-02-17 03:15:09 +01:00
|
|
|
|
if ( aCount !== 0 || bCount !== 0 ) {
|
|
|
|
|
// https://github.com/gorhill/uBlock/issues/471
|
|
|
|
|
aCount = Math.min(Math.ceil(Math.log(aCount + 1) / Math.LN10), 3);
|
|
|
|
|
bCount = Math.min(Math.ceil(Math.log(bCount + 1) / Math.LN10), 3);
|
|
|
|
|
textNode.nodeValue = threePlus.slice(0, aCount) +
|
|
|
|
|
sixSpace.slice(aCount + bCount) +
|
|
|
|
|
threeMinus.slice(0, bCount);
|
|
|
|
|
} else {
|
2015-02-07 21:32:20 +01:00
|
|
|
|
textNode.nodeValue = ' ';
|
2015-02-17 03:15:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( hnDetails.domain !== des ) {
|
2015-01-01 13:29:28 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-02-07 21:32:20 +01:00
|
|
|
|
|
2015-02-17 03:15:09 +01:00
|
|
|
|
textNode = cell.nodeAt(1).firstChild;
|
|
|
|
|
aCount = hnDetails.totalAllowCount;
|
|
|
|
|
bCount = hnDetails.totalBlockCount;
|
|
|
|
|
if ( aCount !== 0 || bCount !== 0 ) {
|
|
|
|
|
// https://github.com/gorhill/uBlock/issues/471
|
|
|
|
|
aCount = Math.min(Math.ceil(Math.log(aCount + 1) / Math.LN10), 3);
|
|
|
|
|
bCount = Math.min(Math.ceil(Math.log(bCount + 1) / Math.LN10), 3);
|
|
|
|
|
textNode.nodeValue = threePlus.slice(0, aCount) +
|
|
|
|
|
sixSpace.slice(aCount + bCount) +
|
|
|
|
|
threeMinus.slice(0, bCount);
|
|
|
|
|
} else {
|
|
|
|
|
textNode.nodeValue = ' ';
|
|
|
|
|
}
|
2014-10-06 20:02:44 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var updateAllFirewallCells = function() {
|
|
|
|
|
var rules = popupData.firewallRules;
|
2015-01-10 17:23:28 +01:00
|
|
|
|
for ( var key in rules ) {
|
2015-01-10 17:44:37 +01:00
|
|
|
|
if ( rules.hasOwnProperty(key) === false ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2015-02-11 06:26:45 +01:00
|
|
|
|
updateFirewallCell(
|
2015-01-10 17:23:28 +01:00
|
|
|
|
key.charAt(0),
|
|
|
|
|
key.slice(2, key.indexOf(' ', 2)),
|
|
|
|
|
key.slice(key.lastIndexOf(' ') + 1),
|
|
|
|
|
rules[key]
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-02-11 06:26:45 +01:00
|
|
|
|
|
|
|
|
|
uDom('#firewallContainer').toggleClass(
|
|
|
|
|
'dirty',
|
|
|
|
|
popupData.matrixIsDirty === true
|
|
|
|
|
);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var buildAllFirewallRows = function() {
|
2015-01-10 17:23:28 +01:00
|
|
|
|
// Do this before removing the rows
|
|
|
|
|
if ( dfHotspots === null ) {
|
2015-02-11 06:26:45 +01:00
|
|
|
|
dfHotspots = uDom('#actionSelector').on('click', 'span', setFirewallRuleHandler);
|
2014-12-30 22:36:29 +01:00
|
|
|
|
}
|
2015-01-10 17:23:28 +01:00
|
|
|
|
dfHotspots.detach();
|
|
|
|
|
|
|
|
|
|
// Remove and reuse all rows: the order may have changed, we can't just
|
|
|
|
|
// reuse them in-place.
|
2015-02-11 06:26:45 +01:00
|
|
|
|
rowsToRecycle = uDom('#firewallContainer > div:nth-of-type(7) ~ div').detach();
|
2015-02-06 23:42:09 +01:00
|
|
|
|
|
2015-02-06 23:46:20 +01:00
|
|
|
|
var n = allHostnameRows.length;
|
2015-02-06 23:42:09 +01:00
|
|
|
|
for ( var i = 0; i < n; i++ ) {
|
2015-02-11 06:26:45 +01:00
|
|
|
|
addFirewallRow(allHostnameRows[i]);
|
2015-02-06 23:42:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( dfPaneBuilt !== true ) {
|
2015-02-11 06:26:45 +01:00
|
|
|
|
uDom('#firewallContainer')
|
|
|
|
|
.on('click', 'span[data-src]', unsetFirewallRuleHandler)
|
2015-02-06 23:42:09 +01:00
|
|
|
|
.on('mouseenter', '[data-src]', mouseenterCellHandler)
|
|
|
|
|
.on('mouseleave', '[data-src]', mouseleaveCellHandler);
|
|
|
|
|
dfPaneBuilt = true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-11 20:44:08 +01:00
|
|
|
|
// The padlock must be manually positioned:
|
|
|
|
|
// - Its horizontal position depends on whether there is a vertical
|
|
|
|
|
// scrollbar.
|
|
|
|
|
var rect = document.getElementById('firewallContainer').getBoundingClientRect();
|
|
|
|
|
document.getElementById('saveRules').style.setProperty('left', (rect.left + 4) + 'px');
|
2015-02-11 06:26:45 +01:00
|
|
|
|
|
|
|
|
|
updateAllFirewallCells();
|
2015-02-06 23:42:09 +01:00
|
|
|
|
};
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
2015-02-06 23:42:09 +01:00
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
var renderPrivacyExposure = function() {
|
2015-01-10 17:23:28 +01:00
|
|
|
|
allDomains = {};
|
|
|
|
|
allDomainCount = touchedDomainCount = 0;
|
2015-02-06 23:46:20 +01:00
|
|
|
|
allHostnameRows = [];
|
2014-12-30 22:36:29 +01:00
|
|
|
|
|
|
|
|
|
// Sort hostnames. First-party hostnames must always appear at the top
|
|
|
|
|
// of the list.
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var desHostnameDone = {};
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var keys = Object.keys(popupData.firewallRules)
|
2015-01-10 17:23:28 +01:00
|
|
|
|
.sort(rulekeyCompare);
|
2015-02-06 23:42:09 +01:00
|
|
|
|
var key, des, hnDetails;
|
2014-12-30 22:36:29 +01:00
|
|
|
|
for ( var i = 0; i < keys.length; i++ ) {
|
|
|
|
|
key = keys[i];
|
2015-01-10 17:23:28 +01:00
|
|
|
|
des = key.slice(2, key.indexOf(' ', 2));
|
2015-02-04 15:03:34 +01:00
|
|
|
|
// Specific-type rules -- these are built-in
|
|
|
|
|
if ( des === '*' || desHostnameDone.hasOwnProperty(des) ) {
|
2015-01-10 17:23:28 +01:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2015-02-06 23:42:09 +01:00
|
|
|
|
hnDetails = popupData.hostnameDict[des] || {};
|
|
|
|
|
if ( allDomains.hasOwnProperty(hnDetails.domain) === false ) {
|
|
|
|
|
allDomains[hnDetails.domain] = false;
|
|
|
|
|
allDomainCount += 1;
|
|
|
|
|
}
|
|
|
|
|
if ( hnDetails.allowCount !== 0 ) {
|
|
|
|
|
if ( allDomains[hnDetails.domain] === false ) {
|
|
|
|
|
allDomains[hnDetails.domain] = true;
|
|
|
|
|
touchedDomainCount += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-02-06 23:46:20 +01:00
|
|
|
|
allHostnameRows.push(des);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
desHostnameDone[des] = true;
|
2014-10-06 20:02:44 +02:00
|
|
|
|
}
|
2014-12-30 22:36:29 +01:00
|
|
|
|
|
2015-03-07 19:20:18 +01:00
|
|
|
|
// The root page domain must always be counted as connected: that's from
|
2015-02-07 19:48:22 +01:00
|
|
|
|
// where the root document was fetched.
|
2015-02-10 16:55:54 +01:00
|
|
|
|
// https://github.com/gorhill/uBlock/issues/759
|
|
|
|
|
// The root page domain must be counted if and only if it was actually
|
|
|
|
|
// obtained through a network request.
|
|
|
|
|
if ( allDomainCount !== 0 && allDomains[popupData.pageDomain] !== true ) {
|
2015-02-07 20:43:17 +01:00
|
|
|
|
allDomains[popupData.pageDomain] = true;
|
2015-02-07 19:48:22 +01:00
|
|
|
|
touchedDomainCount += 1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-06 23:42:09 +01:00
|
|
|
|
var summary = domainsHitStr.replace('{{count}}', touchedDomainCount.toLocaleString())
|
|
|
|
|
.replace('{{total}}', allDomainCount.toLocaleString());
|
2015-02-07 00:20:33 +01:00
|
|
|
|
uDom('#popupHitDomainCount').text(summary);
|
2014-10-06 20:02:44 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
// Assume everything has to be done incrementally.
|
|
|
|
|
|
2015-03-02 19:49:34 +01:00
|
|
|
|
var renderPopup = function () {
|
|
|
|
|
if (popupData.tabTitle) {
|
|
|
|
|
document.title = popupData.appName + " - " + popupData.tabTitle;
|
|
|
|
|
}
|
2015-01-06 14:01:15 +01:00
|
|
|
|
uDom('#appname').text(popupData.appName);
|
|
|
|
|
uDom('#version').text(popupData.appVersion);
|
2015-01-06 17:44:06 +01:00
|
|
|
|
uDom('body').toggleClass('advancedUser', popupData.advancedUserEnabled);
|
2015-01-24 18:06:22 +01:00
|
|
|
|
|
2015-02-09 21:24:24 +01:00
|
|
|
|
uDom('body').toggleClass(
|
2015-01-24 18:06:22 +01:00
|
|
|
|
'off',
|
|
|
|
|
(popupData.pageURL === '') ||
|
|
|
|
|
(!popupData.netFilteringSwitch) ||
|
|
|
|
|
(popupData.pageHostname === 'behind-the-scene' && !popupData.advancedUserEnabled)
|
|
|
|
|
);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
2015-01-21 17:13:32 +01:00
|
|
|
|
// If you think the `=== true` is pointless, you are mistaken
|
|
|
|
|
uDom('#gotoLog').toggleClass('enabled', popupData.canRequestLog === true)
|
|
|
|
|
.attr('href', 'devtools.html?tabId=' + popupData.tabId);
|
|
|
|
|
uDom('#gotoPick').toggleClass('enabled', popupData.canElementPicker === true);
|
2014-07-02 18:02:29 +02:00
|
|
|
|
|
2015-01-06 14:01:15 +01:00
|
|
|
|
var blocked = popupData.pageBlockedRequestCount;
|
|
|
|
|
var total = popupData.pageAllowedRequestCount + blocked;
|
2015-02-06 23:42:09 +01:00
|
|
|
|
var text = [];
|
2014-06-24 00:42:43 +02:00
|
|
|
|
if ( total === 0 ) {
|
2015-02-07 00:20:33 +01:00
|
|
|
|
text.push(formatNumber(0));
|
2014-06-24 00:42:43 +02:00
|
|
|
|
} else {
|
2015-02-06 23:42:09 +01:00
|
|
|
|
text.push(
|
2014-06-24 07:20:59 +02:00
|
|
|
|
formatNumber(blocked),
|
2015-02-06 23:42:09 +01:00
|
|
|
|
'\u00a0', orStr, '\u00a0',
|
|
|
|
|
formatNumber(Math.floor(blocked * 100 / total)), '%'
|
2014-07-02 18:02:29 +02:00
|
|
|
|
);
|
2014-06-24 00:42:43 +02:00
|
|
|
|
}
|
2015-02-06 23:42:09 +01:00
|
|
|
|
uDom('#page-blocked').text(text.join(''));
|
2014-06-24 00:42:43 +02:00
|
|
|
|
|
2015-01-06 14:01:15 +01:00
|
|
|
|
blocked = popupData.globalBlockedRequestCount;
|
|
|
|
|
total = popupData.globalAllowedRequestCount + blocked;
|
2015-02-06 23:42:09 +01:00
|
|
|
|
text = [];
|
2014-06-24 00:42:43 +02:00
|
|
|
|
if ( total === 0 ) {
|
2015-02-07 00:20:33 +01:00
|
|
|
|
text.push(formatNumber(0));
|
2014-06-24 00:42:43 +02:00
|
|
|
|
} else {
|
2015-02-06 23:42:09 +01:00
|
|
|
|
text.push(
|
2014-06-24 07:20:59 +02:00
|
|
|
|
formatNumber(blocked),
|
2015-02-06 23:42:09 +01:00
|
|
|
|
'\u00a0', orStr, '\u00a0',
|
|
|
|
|
formatNumber(Math.floor(blocked * 100 / total)), '%'
|
2014-07-02 18:02:29 +02:00
|
|
|
|
);
|
2014-06-24 00:42:43 +02:00
|
|
|
|
}
|
2015-02-06 23:42:09 +01:00
|
|
|
|
uDom('#total-blocked').text(text.join(''));
|
|
|
|
|
|
|
|
|
|
// This will collate all domains, touched or not
|
|
|
|
|
renderPrivacyExposure();
|
2014-06-24 00:42:43 +02:00
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
// https://github.com/gorhill/uBlock/issues/470
|
|
|
|
|
// This must be done here, to be sure the popup is resized properly
|
|
|
|
|
var dfPaneVisible = popupData.dfEnabled && popupData.advancedUserEnabled;
|
|
|
|
|
|
|
|
|
|
uDom('#panes').toggleClass('dfEnabled', dfPaneVisible);
|
2015-02-17 03:15:09 +01:00
|
|
|
|
uDom('#firewallContainer').toggleClass('minimized', popupData.firewallPaneMinimized);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
2015-01-06 14:01:15 +01:00
|
|
|
|
// Build dynamic filtering pane only if in use
|
2015-01-10 17:23:28 +01:00
|
|
|
|
if ( dfPaneVisible ) {
|
2015-02-11 06:26:45 +01:00
|
|
|
|
buildAllFirewallRows();
|
2015-01-06 14:01:15 +01:00
|
|
|
|
}
|
2014-06-24 00:42:43 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2014-08-02 17:40:27 +02:00
|
|
|
|
var toggleNetFilteringSwitch = function(ev) {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
if ( !popupData || !popupData.pageURL ) {
|
2014-06-24 00:42:43 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-01-24 18:06:22 +01:00
|
|
|
|
if ( popupData.pageHostname === 'behind-the-scene' && !popupData.advancedUserEnabled ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-10-17 21:44:19 +02:00
|
|
|
|
messager.send({
|
2014-06-24 00:42:43 +02:00
|
|
|
|
what: 'toggleNetFiltering',
|
2015-01-06 14:01:15 +01:00
|
|
|
|
url: popupData.pageURL,
|
2014-08-02 17:40:27 +02:00
|
|
|
|
scope: ev.ctrlKey || ev.metaKey ? 'page' : '',
|
2015-02-09 21:24:24 +01:00
|
|
|
|
state: !uDom('body').toggleClass('off').hasClass('off'),
|
2015-01-06 14:01:15 +01:00
|
|
|
|
tabId: popupData.tabId
|
2014-06-24 00:42:43 +02:00
|
|
|
|
});
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
|
|
|
|
hashFromPopupData();
|
2014-06-24 00:42:43 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2014-07-13 02:32:44 +02:00
|
|
|
|
var gotoPick = function() {
|
2014-10-17 21:44:19 +02:00
|
|
|
|
messager.send({
|
2014-07-13 02:32:44 +02:00
|
|
|
|
what: 'gotoPick',
|
2015-03-02 19:49:34 +01:00
|
|
|
|
tabId: popupData.tabId,
|
|
|
|
|
select: true
|
|
|
|
|
});
|
2014-12-25 14:53:30 +01:00
|
|
|
|
|
|
|
|
|
vAPI.closePopup();
|
2014-07-13 02:32:44 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2014-12-25 14:53:30 +01:00
|
|
|
|
var gotoURL = function(ev) {
|
2014-12-28 21:26:06 +01:00
|
|
|
|
if ( this.hasAttribute('href') === false) {
|
2014-10-20 17:40:52 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
|
|
|
|
|
messager.send({
|
|
|
|
|
what: 'gotoURL',
|
|
|
|
|
details: {
|
2014-12-25 14:53:30 +01:00
|
|
|
|
url: this.getAttribute('href'),
|
2014-10-20 17:40:52 +02:00
|
|
|
|
select: true,
|
|
|
|
|
index: -1
|
|
|
|
|
}
|
|
|
|
|
});
|
2014-12-25 14:53:30 +01:00
|
|
|
|
|
|
|
|
|
vAPI.closePopup();
|
2014-07-02 18:02:29 +02:00
|
|
|
|
};
|
2014-06-24 00:42:43 +02:00
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var toggleFirewallPane = function() {
|
2015-01-10 17:23:28 +01:00
|
|
|
|
if ( popupData.advancedUserEnabled === false ) {
|
2015-01-06 17:44:06 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-01-06 14:01:15 +01:00
|
|
|
|
popupData.dfEnabled = !popupData.dfEnabled;
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
2014-12-31 16:47:19 +01:00
|
|
|
|
messager.send({
|
|
|
|
|
what: 'userSettings',
|
|
|
|
|
name: 'dynamicFilteringEnabled',
|
2015-01-06 14:01:15 +01:00
|
|
|
|
value: popupData.dfEnabled
|
2015-01-10 17:23:28 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Dynamic filtering pane may not have been built yet
|
|
|
|
|
uDom('#panes').toggleClass('dfEnabled', popupData.dfEnabled);
|
|
|
|
|
if ( popupData.dfEnabled && dfPaneBuilt === false ) {
|
2015-02-11 06:26:45 +01:00
|
|
|
|
buildAllFirewallRows();
|
2015-01-10 17:23:28 +01:00
|
|
|
|
}
|
2014-12-31 16:47:19 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
var mouseenterCellHandler = function() {
|
|
|
|
|
if ( uDom(this).hasClass('ownRule') === false ) {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
dfHotspots.appendTo(this);
|
2014-12-31 16:47:19 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var mouseleaveCellHandler = function() {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
dfHotspots.detach();
|
2014-12-31 16:47:19 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 21:48:39 +01:00
|
|
|
|
var setFirewallRule = function(src, des, type, action, persist) {
|
2014-12-28 16:07:43 +01:00
|
|
|
|
// This can happen on pages where uBlock does not work
|
2015-01-06 14:01:15 +01:00
|
|
|
|
if ( typeof popupData.pageHostname !== 'string' || popupData.pageHostname === '' ) {
|
2014-12-28 16:07:43 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-02-11 06:26:45 +01:00
|
|
|
|
var onFirewallRuleChanged = function(response) {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
cachePopupData(response);
|
2015-02-11 06:26:45 +01:00
|
|
|
|
updateAllFirewallCells();
|
2015-01-10 17:23:28 +01:00
|
|
|
|
hashFromPopupData();
|
2014-10-06 20:02:44 +02:00
|
|
|
|
};
|
2014-10-17 21:44:19 +02:00
|
|
|
|
messager.send({
|
2015-02-11 06:26:45 +01:00
|
|
|
|
what: 'toggleFirewallRule',
|
2015-01-06 14:01:15 +01:00
|
|
|
|
tabId: popupData.tabId,
|
|
|
|
|
pageHostname: popupData.pageHostname,
|
2014-12-31 16:47:19 +01:00
|
|
|
|
srcHostname: src,
|
|
|
|
|
desHostname: des,
|
|
|
|
|
requestType: type,
|
2015-02-11 21:48:39 +01:00
|
|
|
|
action: action,
|
|
|
|
|
persist: persist
|
2015-02-11 06:26:45 +01:00
|
|
|
|
}, onFirewallRuleChanged);
|
2014-10-06 20:02:44 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 21:48:39 +01:00
|
|
|
|
var unsetFirewallRuleHandler = function(ev) {
|
2014-12-31 16:47:19 +01:00
|
|
|
|
var cell = uDom(this);
|
2015-02-11 06:26:45 +01:00
|
|
|
|
setFirewallRule(
|
2015-01-06 14:01:15 +01:00
|
|
|
|
cell.attr('data-src') === '/' ? '*' : popupData.pageHostname,
|
2014-12-31 16:47:19 +01:00
|
|
|
|
cell.attr('data-des'),
|
|
|
|
|
cell.attr('data-type'),
|
2015-02-11 21:48:39 +01:00
|
|
|
|
0,
|
|
|
|
|
ev.ctrlKey || ev.metaKey
|
2014-12-31 16:47:19 +01:00
|
|
|
|
);
|
2015-01-06 14:01:15 +01:00
|
|
|
|
dfHotspots.appendTo(cell);
|
2014-12-31 16:47:19 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 21:48:39 +01:00
|
|
|
|
var setFirewallRuleHandler = function(ev) {
|
2014-12-31 16:47:19 +01:00
|
|
|
|
var hotspot = uDom(this);
|
|
|
|
|
var cell = hotspot.ancestors('[data-src]');
|
|
|
|
|
if ( cell.length === 0 ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var action = 0;
|
|
|
|
|
var hotspotId = hotspot.attr('id');
|
|
|
|
|
if ( hotspotId === 'dynaAllow' ) {
|
|
|
|
|
action = 2;
|
|
|
|
|
} else if ( hotspotId === 'dynaNoop' ) {
|
2015-01-10 17:44:37 +01:00
|
|
|
|
action = 3;
|
2014-12-31 16:47:19 +01:00
|
|
|
|
} else {
|
|
|
|
|
action = 1;
|
|
|
|
|
}
|
2015-02-11 06:26:45 +01:00
|
|
|
|
setFirewallRule(
|
2015-01-06 14:01:15 +01:00
|
|
|
|
cell.attr('data-src') === '/' ? '*' : popupData.pageHostname,
|
2014-12-31 16:47:19 +01:00
|
|
|
|
cell.attr('data-des'),
|
|
|
|
|
cell.attr('data-type'),
|
2015-02-11 21:48:39 +01:00
|
|
|
|
action,
|
|
|
|
|
ev.ctrlKey || ev.metaKey
|
2014-12-31 16:47:19 +01:00
|
|
|
|
);
|
2015-01-06 14:01:15 +01:00
|
|
|
|
dfHotspots.detach();
|
2014-10-06 20:02:44 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var reloadTab = function() {
|
2015-03-02 19:49:34 +01:00
|
|
|
|
messager.send({ what: 'reloadTab', tabId: popupData.tabId, select: true });
|
2015-01-06 14:01:15 +01:00
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
// Polling will take care of refreshing the popup content
|
2015-02-09 21:24:24 +01:00
|
|
|
|
|
|
|
|
|
// https://github.com/gorhill/uBlock/issues/748
|
|
|
|
|
// User forces a reload, assume the popup has to be updated regardless if
|
|
|
|
|
// there were changes or not.
|
|
|
|
|
popupData.contentLastModified = -1;
|
|
|
|
|
|
2015-02-09 21:35:47 +01:00
|
|
|
|
// No need to wait to remove this.
|
2015-02-09 21:24:24 +01:00
|
|
|
|
uDom('body').toggleClass('dirty', false);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-17 03:15:09 +01:00
|
|
|
|
var toggleMinimize = function() {
|
|
|
|
|
var elem = uDom('#firewallContainer');
|
|
|
|
|
elem.toggleClass('minimized');
|
|
|
|
|
popupData.firewallPaneMinimized = elem.hasClass('minimized');
|
|
|
|
|
messager.send({
|
|
|
|
|
what: 'userSettings',
|
|
|
|
|
name: 'firewallPaneMinimized',
|
|
|
|
|
value: popupData.firewallPaneMinimized
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-02-11 21:48:39 +01:00
|
|
|
|
var saveFirewallRules = function() {
|
|
|
|
|
messager.send({
|
|
|
|
|
what: 'saveFirewallRules',
|
|
|
|
|
srcHostname: popupData.pageHostname,
|
|
|
|
|
desHostnames: popupData.hostnameDict
|
2015-02-11 06:26:45 +01:00
|
|
|
|
});
|
|
|
|
|
uDom('#firewallContainer').removeClass('dirty');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-01-10 17:23:28 +01:00
|
|
|
|
// Poll for changes.
|
|
|
|
|
//
|
|
|
|
|
// I couldn't find a better way to be notified of changes which can affect
|
|
|
|
|
// popup content, as the messaging API doesn't support firing events accurately
|
|
|
|
|
// from the main extension process to a specific auxiliary extension process:
|
|
|
|
|
//
|
|
|
|
|
// - broadcasting() is not an option given there could be a lot of tabs opened,
|
2014-12-25 14:53:30 +01:00
|
|
|
|
// and maybe even many frames within these tabs, i.e. unacceptable overhead
|
2015-01-10 17:32:24 +01:00
|
|
|
|
// regardless of whether the popup is opened or not.
|
2015-01-10 17:23:28 +01:00
|
|
|
|
//
|
|
|
|
|
// - Modifying the messaging API is not an option, as this would require
|
|
|
|
|
// revisiting all platform-specific code to support targeted broadcasting,
|
|
|
|
|
// which who knows could be not so trivial for some platforms.
|
|
|
|
|
//
|
2014-12-25 14:53:30 +01:00
|
|
|
|
// A well done polling is a better anyways IMO, I prefer that data is pulled
|
2015-01-10 17:32:24 +01:00
|
|
|
|
// on demand rather than forcing the main process to assume a client may need
|
|
|
|
|
// it and thus having to push it all the time unconditionally.
|
2015-01-10 17:23:28 +01:00
|
|
|
|
|
|
|
|
|
var pollForContentChange = (function() {
|
|
|
|
|
var pollTimer = null;
|
|
|
|
|
|
|
|
|
|
var pollCallback = function() {
|
|
|
|
|
pollTimer = null;
|
|
|
|
|
messager.send(
|
|
|
|
|
{
|
|
|
|
|
what: 'hasPopupContentChanged',
|
|
|
|
|
tabId: popupData.tabId,
|
|
|
|
|
contentLastModified: popupData.contentLastModified
|
|
|
|
|
},
|
|
|
|
|
queryCallback
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var queryCallback = function(response) {
|
|
|
|
|
if ( response ) {
|
2015-03-02 19:49:34 +01:00
|
|
|
|
getPopupData(popupData.tabId);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
poll();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var poll = function() {
|
|
|
|
|
if ( pollTimer !== null ) {
|
2015-01-06 14:01:15 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-01-10 17:23:28 +01:00
|
|
|
|
pollTimer = setTimeout(pollCallback, 1500);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return poll;
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
2015-03-02 19:49:34 +01:00
|
|
|
|
var getPopupData = function(tabId) {
|
2015-01-10 17:23:28 +01:00
|
|
|
|
var onDataReceived = function(response) {
|
|
|
|
|
cachePopupData(response);
|
2015-01-06 14:01:15 +01:00
|
|
|
|
renderPopup();
|
2015-01-10 17:23:28 +01:00
|
|
|
|
hashFromPopupData(true);
|
|
|
|
|
pollForContentChange();
|
|
|
|
|
};
|
2015-03-02 19:49:34 +01:00
|
|
|
|
messager.send({ what: 'getPopupData', tabId: tabId }, onDataReceived);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
// Make menu only when popup html is fully loaded
|
|
|
|
|
|
2015-03-02 19:49:34 +01:00
|
|
|
|
uDom.onLoad(function () {
|
|
|
|
|
var tabId = null; //If there's no tab ID specified in the query string, it will default to current tab.
|
|
|
|
|
|
|
|
|
|
// Extract the tab id of the page this popup is for
|
|
|
|
|
var matches = window.location.search.match(/[\?&]tabId=([^&]+)/);
|
|
|
|
|
if (matches && matches.length === 2) {
|
|
|
|
|
tabId = matches[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getPopupData(tabId);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
uDom('#switch').on('click', toggleNetFilteringSwitch);
|
2014-07-13 02:32:44 +02:00
|
|
|
|
uDom('#gotoPick').on('click', gotoPick);
|
2014-12-25 14:53:30 +01:00
|
|
|
|
uDom('a[href]').on('click', gotoURL);
|
2015-02-11 06:26:45 +01:00
|
|
|
|
uDom('h2').on('click', toggleFirewallPane);
|
2015-01-10 17:23:28 +01:00
|
|
|
|
uDom('#refresh').on('click', reloadTab);
|
2015-02-11 21:48:39 +01:00
|
|
|
|
uDom('#saveRules').on('click', saveFirewallRules);
|
2015-02-17 03:15:09 +01:00
|
|
|
|
uDom('[data-i18n="popupAnyRulePrompt"]').on('click', toggleMinimize);
|
2014-06-24 00:42:43 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
})();
|