diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 4c66e84..e03bb85 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -119,6 +119,10 @@
"message": "Referrer spoofing",
"description": "A menu entry in the matrix popup"
},
+ "matrixSwitchNoscriptSpoof" : {
+ "message": "
tags spoofing",
+ "description": "A menu entry in the matrix popup"
+ },
"matrixRevertAllEntry" : {
"message": "Revert all temporary changes",
"description": "A menu entry in the matrix popup"
@@ -338,6 +342,10 @@
"message": "Collapse placeholder of blocked elements",
"description": "English: Collapse placeholder of blocked elements"
},
+ "settingsNoscriptTagsSpoofed" : {
+ "message": "Spoof
tags when 1st-party scripts are blocked",
+ "description": "This appears in the Settings pane in the dashboard"
+ },
"settingsCloudStorageEnabled" : {
"message": "Enable cloud storage support",
"description": ""
diff --git a/src/css/common.css b/src/css/common.css
index 4910575..225aa30 100644
--- a/src/css/common.css
+++ b/src/css/common.css
@@ -113,3 +113,6 @@ button.custom[disabled] {
opacity: 0.6;
pointer-events: none;
}
+code {
+ font-size: 90%;
+ }
diff --git a/src/dashboard.html b/src/dashboard.html
index 4aa231c..629cb35 100644
--- a/src/dashboard.html
+++ b/src/dashboard.html
@@ -82,7 +82,6 @@ iframe {
uMatrix
-
diff --git a/src/js/contentscript.js b/src/js/contentscript.js
index f4cf7b2..443ea84 100644
--- a/src/js/contentscript.js
+++ b/src/js/contentscript.js
@@ -493,6 +493,31 @@ var nodeListsAddedHandler = function(nodeLists) {
/******************************************************************************/
/******************************************************************************/
+// Executed only once.
+
+(function() {
+ var noscripts = document.querySelectorAll('noscript');
+ if ( noscripts.length === 0 ) { return; }
+
+ var renderNoscriptTags = function(response) {
+ if ( response !== true ) { return; }
+
+ var parent, span;
+ for ( var noscript of noscripts ) {
+ parent = noscript.parentNode;
+ if ( parent === null ) { continue; }
+ span = document.createElement('span');
+ span.innerHTML = noscript.textContent;
+ parent.replaceChild(span, noscript);
+ }
+ };
+
+ localMessager.send({ what: 'mustRenderNoscriptTags?' }, renderNoscriptTags);
+})();
+
+/******************************************************************************/
+/******************************************************************************/
+
localMessager.send({ what: 'shutdown?' }, function(response) {
if ( response === true ) {
vAPI.shutdown.exec();
diff --git a/src/js/matrix.js b/src/js/matrix.js
index 537f72a..bcfad2e 100644
--- a/src/js/matrix.js
+++ b/src/js/matrix.js
@@ -90,7 +90,8 @@ var switchBitOffsets = new Map([
[ 'matrix-off', 0 ],
[ 'https-strict', 2 ],
/* 4 is now unused, formerly assigned to UA spoofing */
- [ 'referrer-spoof', 6 ]
+ [ 'referrer-spoof', 6 ],
+ [ 'noscript-spoof', 8 ]
]);
var switchStateToNameMap = new Map([
diff --git a/src/js/messaging.js b/src/js/messaging.js
index 05e34c0..444c277 100644
--- a/src/js/messaging.js
+++ b/src/js/messaging.js
@@ -63,7 +63,14 @@ function onMessage(request, sender, callback) {
break;
case 'getUserSettings':
- response = µm.userSettings;
+ response = {
+ userSettings: µm.userSettings,
+ matrixSwitches: {
+ 'https-strict': µm.pMatrix.evaluateSwitch('https-strict', '*') === 1,
+ 'referrer-spoof': µm.pMatrix.evaluateSwitch('referrer-spoof', '*') === 1,
+ 'noscript-spoof': µm.pMatrix.evaluateSwitch('noscript-spoof', '*') === 1
+ }
+ };
break;
case 'gotoExtensionURL':
@@ -86,6 +93,13 @@ function onMessage(request, sender, callback) {
µm.reloadHostsFiles();
break;
+ case 'setMatrixSwitch':
+ µm.tMatrix.setSwitch(request.switchName, '*', request.state);
+ if ( µm.pMatrix.setSwitch(request.switchName, '*', request.state) ) {
+ µm.saveMatrix();
+ }
+ break;
+
case 'userSettings':
if ( request.hasOwnProperty('value') === false ) {
request.value = undefined;
@@ -519,6 +533,7 @@ var onMessage = function(request, sender, callback) {
}
var tabId = sender && sender.tab ? sender.tab.id || 0 : 0;
+ var tabContext = µm.tabContextManager.lookup(tabId);
// Sync
var response;
@@ -536,8 +551,15 @@ var onMessage = function(request, sender, callback) {
response = evaluateURLs(tabId, request.requests);
break;
+ case 'mustRenderNoscriptTags?':
+ if ( tabContext !== null ) {
+ response =
+ µm.tMatrix.mustBlock(tabContext.rootHostname, tabContext.rootHostname, 'script') &&
+ µm.tMatrix.evaluateSwitchZ('noscript-spoof', tabContext.rootHostname);
+ }
+ break;
+
case 'shutdown?':
- var tabContext = µm.tabContextManager.lookup(tabId);
if ( tabContext !== null ) {
response = µm.tMatrix.evaluateSwitchZ('matrix-off', tabContext.rootHostname);
}
@@ -619,85 +641,6 @@ vAPI.messaging.listen('cloud-ui.js', onMessage);
/******************************************************************************/
/******************************************************************************/
-// settings.js
-
-(function() {
-
-var onMessage = function(request, sender, callback) {
- var µm = µMatrix;
-
- // Async
- switch ( request.what ) {
- default:
- break;
- }
-
- // Sync
- var response;
-
- switch ( request.what ) {
- default:
- return vAPI.messaging.UNHANDLED;
- }
-
- callback(response);
-};
-
-vAPI.messaging.listen('settings.js', onMessage);
-
-})();
-
-/******************************************************************************/
-/******************************************************************************/
-
-// privacy.js
-
-(function() {
-
-var onMessage = function(request, sender, callback) {
- var µm = µMatrix;
-
- // Async
- switch ( request.what ) {
- default:
- break;
- }
-
- // Sync
- var response;
-
- switch ( request.what ) {
- case 'getPrivacySettings':
- response = {
- userSettings: µm.userSettings,
- matrixSwitches: {
- 'https-strict': µm.pMatrix.evaluateSwitch('https-strict', '*') === 1,
- 'referrer-spoof': µm.pMatrix.evaluateSwitch('referrer-spoof', '*') === 1
- }
- };
- break;
-
- case 'setMatrixSwitch':
- µm.tMatrix.setSwitch(request.switchName, '*', request.state);
- if ( µm.pMatrix.setSwitch(request.switchName, '*', request.state) ) {
- µm.saveMatrix();
- }
- break;
-
- default:
- return vAPI.messaging.UNHANDLED;
- }
-
- callback(response);
-};
-
-vAPI.messaging.listen('privacy.js', onMessage);
-
-})();
-
-/******************************************************************************/
-/******************************************************************************/
-
// user-rules.js
(function() {
diff --git a/src/js/privacy.js b/src/js/privacy.js
deleted file mode 100644
index 7c3a3cc..0000000
--- a/src/js/privacy.js
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
-
- 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
- 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/uMatrix
-*/
-
-/* global vAPI, uDom */
-
-'use strict';
-
-/******************************************************************************/
-
-(function() {
-
-/******************************************************************************/
-
-var messager = vAPI.messaging.channel('privacy.js');
-
-var cachedPrivacySettings = {};
-
-/******************************************************************************/
-
-function changeUserSettings(name, value) {
- messager.send({
- what: 'userSettings',
- name: name,
- value: value
- });
-}
-
-/******************************************************************************/
-
-function changeMatrixSwitch(name, state) {
- messager.send({
- what: 'setMatrixSwitch',
- switchName: name,
- state: state
- });
-}
-
-/******************************************************************************/
-
-function onChangeValueHandler(uelem, setting, min, max) {
- var oldVal = cachedPrivacySettings.userSettings[setting];
- var newVal = Math.round(parseFloat(uelem.val()));
- if ( typeof newVal !== 'number' ) {
- newVal = oldVal;
- } else {
- newVal = Math.max(newVal, min);
- newVal = Math.min(newVal, max);
- }
- uelem.val(newVal);
- if ( newVal !== oldVal ) {
- changeUserSettings(setting, newVal);
- }
-}
-
-/******************************************************************************/
-
-function prepareToDie() {
- onChangeValueHandler(uDom('#delete-unused-session-cookies-after'), 'deleteUnusedSessionCookiesAfter', 15, 1440);
- onChangeValueHandler(uDom('#clear-browser-cache-after'), 'clearBrowserCacheAfter', 15, 1440);
-}
-
-/******************************************************************************/
-
-var installEventHandlers = function() {
- uDom('[data-setting-bool]').on('change', function(){
- var settingName = this.getAttribute('data-setting-bool');
- if ( typeof settingName === 'string' && settingName !== '' ) {
- changeUserSettings(settingName, this.checked);
- }
- });
-
- uDom('[data-matrix-switch]').on('change', function(){
- var switchName = this.getAttribute('data-matrix-switch');
- if ( typeof switchName === 'string' && switchName !== '' ) {
- changeMatrixSwitch(switchName, this.checked);
- }
- });
-
- uDom('#delete-unused-session-cookies-after').on('change', function(){
- onChangeValueHandler(uDom(this), 'deleteUnusedSessionCookiesAfter', 15, 1440);
- });
- uDom('#clear-browser-cache-after').on('change', function(){
- onChangeValueHandler(uDom(this), 'clearBrowserCacheAfter', 15, 1440);
- });
-
- // https://github.com/gorhill/httpswitchboard/issues/197
- uDom(window).on('beforeunload', prepareToDie);
-};
-
-/******************************************************************************/
-
-uDom.onLoad(function() {
- var onSettingsReceived = function(privacySettings) {
- // Cache copy
- cachedPrivacySettings = privacySettings;
-
- var userSettings = privacySettings.userSettings;
- var matrixSwitches = privacySettings.matrixSwitches;
-
- uDom('[data-setting-bool]').forEach(function(elem){
- var settingName = elem.attr('data-setting-bool');
- if ( typeof settingName === 'string' && settingName !== '' ) {
- elem.prop('checked', userSettings[settingName] === true);
- }
- });
-
- uDom('[data-matrix-switch]').forEach(function(elem){
- var switchName = elem.attr('data-matrix-switch');
- if ( typeof switchName === 'string' && switchName !== '' ) {
- elem.prop('checked', matrixSwitches[switchName] === true);
- }
- });
-
- uDom('#delete-unused-session-cookies-after').val(userSettings.deleteUnusedSessionCookiesAfter);
- uDom('#clear-browser-cache-after').val(userSettings.clearBrowserCacheAfter);
-
- installEventHandlers();
- };
- messager.send({ what: 'getPrivacySettings' }, onSettingsReceived);
-});
-
-/******************************************************************************/
-
-})();
diff --git a/src/js/settings.js b/src/js/settings.js
index 273758f..d37ca49 100644
--- a/src/js/settings.js
+++ b/src/js/settings.js
@@ -1,7 +1,7 @@
/*******************************************************************************
- µMatrix - a Chromium browser extension to black/white list requests.
- Copyright (C) 2014 Raymond Hill
+ 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
it under the terms of the GNU General Public License as published by
@@ -22,17 +22,17 @@
/* global vAPI, uDom */
/* jshint multistr: true */
+'use strict';
+
/******************************************************************************/
(function() {
-'use strict';
-
/******************************************************************************/
var messager = vAPI.messaging.channel('settings.js');
-var cachedUserSettings = {};
+var cachedSettings = {};
/******************************************************************************/
@@ -46,18 +46,41 @@ function changeUserSettings(name, value) {
/******************************************************************************/
+function changeMatrixSwitch(name, state) {
+ messager.send({
+ what: 'setMatrixSwitch',
+ switchName: name,
+ state: state
+ });
+}
+
+/******************************************************************************/
+
+function onChangeValueHandler(uelem, setting, min, max) {
+ var oldVal = cachedSettings.userSettings[setting];
+ var newVal = Math.round(parseFloat(uelem.val()));
+ if ( typeof newVal !== 'number' ) {
+ newVal = oldVal;
+ } else {
+ newVal = Math.max(newVal, min);
+ newVal = Math.min(newVal, max);
+ }
+ uelem.val(newVal);
+ if ( newVal !== oldVal ) {
+ changeUserSettings(setting, newVal);
+ }
+}
+
+/******************************************************************************/
+
function prepareToDie() {
+ onChangeValueHandler(uDom('#delete-unused-session-cookies-after'), 'deleteUnusedSessionCookiesAfter', 15, 1440);
+ onChangeValueHandler(uDom('#clear-browser-cache-after'), 'clearBrowserCacheAfter', 15, 1440);
}
/******************************************************************************/
var installEventHandlers = function() {
- // `data-range` allows to add/remove bool properties without
- // changing code.
- uDom('input[data-range="bool"]').on('change', function() {
- changeUserSettings(this.id, this.checked);
- });
-
uDom('input[name="displayTextSize"]').on('change', function(){
changeUserSettings('displayTextSize', this.value);
});
@@ -66,6 +89,27 @@ var installEventHandlers = function() {
changeUserSettings('popupScopeLevel', this.value);
});
+ uDom('[data-setting-bool]').on('change', function(){
+ var settingName = this.getAttribute('data-setting-bool');
+ if ( typeof settingName === 'string' && settingName !== '' ) {
+ changeUserSettings(settingName, this.checked);
+ }
+ });
+
+ uDom('[data-matrix-switch]').on('change', function(){
+ var switchName = this.getAttribute('data-matrix-switch');
+ if ( typeof switchName === 'string' && switchName !== '' ) {
+ changeMatrixSwitch(switchName, this.checked);
+ }
+ });
+
+ uDom('#delete-unused-session-cookies-after').on('change', function(){
+ onChangeValueHandler(uDom(this), 'deleteUnusedSessionCookiesAfter', 15, 1440);
+ });
+ uDom('#clear-browser-cache-after').on('change', function(){
+ onChangeValueHandler(uDom(this), 'clearBrowserCacheAfter', 15, 1440);
+ });
+
// https://github.com/gorhill/httpswitchboard/issues/197
uDom(window).on('beforeunload', prepareToDie);
};
@@ -73,14 +117,25 @@ var installEventHandlers = function() {
/******************************************************************************/
uDom.onLoad(function() {
- var onUserSettingsReceived = function(userSettings) {
+ var onSettingsReceived = function(settings) {
// Cache copy
- cachedUserSettings = userSettings;
+ cachedSettings = settings;
+
+ var userSettings = settings.userSettings;
+ var matrixSwitches = settings.matrixSwitches;
- // `data-range` allows to add/remove bool properties without
- // changing code.
- uDom('input[data-range="bool"]').forEach(function(elem) {
- elem.prop('checked', userSettings[elem.attr('id')] === true);
+ uDom('[data-setting-bool]').forEach(function(elem){
+ var settingName = elem.attr('data-setting-bool');
+ if ( typeof settingName === 'string' && settingName !== '' ) {
+ elem.prop('checked', userSettings[settingName] === true);
+ }
+ });
+
+ uDom('[data-matrix-switch]').forEach(function(elem){
+ var switchName = elem.attr('data-matrix-switch');
+ if ( typeof switchName === 'string' && switchName !== '' ) {
+ elem.prop('checked', matrixSwitches[switchName] === true);
+ }
});
uDom('input[name="displayTextSize"]').forEach(function(elem) {
@@ -89,9 +144,12 @@ uDom.onLoad(function() {
uDom.nodeFromId('popupScopeLevel').value = userSettings.popupScopeLevel;
+ uDom('#delete-unused-session-cookies-after').val(userSettings.deleteUnusedSessionCookiesAfter);
+ uDom('#clear-browser-cache-after').val(userSettings.clearBrowserCacheAfter);
+
installEventHandlers();
};
- messager.send({ what: 'getUserSettings' }, onUserSettingsReceived);
+ messager.send({ what: 'getUserSettings' }, onSettingsReceived);
});
/******************************************************************************/
diff --git a/src/popup.html b/src/popup.html
index ee42831..8b085dc 100644
--- a/src/popup.html
+++ b/src/popup.html
@@ -31,6 +31,7 @@
diff --git a/src/privacy.html b/src/privacy.html
deleted file mode 100644
index 7d9bf7e..0000000
--- a/src/privacy.html
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-