xiMatrix

filter net requests according to source, destination and type  https://addons.mozilla.org/firefox/addon/ximatrix/
git clone https://git.ce9e.org/xiMatrix.git

commit
641f2b5c18d07ec8ec8e0f3e234566bb88ccc084
parent
ebb0c9a4b0780cda266de38fd6df2d05e7104332
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-08-07 20:43
allow to edit raw rules

Diffstat

M src/bg.js 6 ++++++
M src/popup.css 6 ++++++
M src/popup.html 10 ++++++++++
M src/popup.js 17 +++++++++++++++++

4 files changed, 39 insertions, 0 deletions


diff --git a/src/bg.js b/src/bg.js

@@ -83,6 +83,12 @@ browser.runtime.onMessage.addListener((msg, sender) => {
   83    83             msg.data.value,
   84    84         );
   85    85         return Promise.resolve(restrictRules(msg.data.context));
   -1    86     } else if (msg.type === 'getAllRules') {
   -1    87         return Promise.resolve(rules);
   -1    88     } else if (msg.type === 'setAllRules') {
   -1    89         rules = msg.data;
   -1    90         browser.storage.local.set({'rules': rules});
   -1    91         return Promise.resolve();
   86    92     } else if (msg.type === 'securitypolicyviolation') {
   87    93         pushRequest(sender.tab.id, 'inline', msg.data);
   88    94     }

diff --git a/src/popup.css b/src/popup.css

@@ -53,3 +53,9 @@ input ~ span {
   53    53 input:checked ~ span {
   54    54 	color: var(--text-dark);
   55    55 }
   -1    56 
   -1    57 textarea {
   -1    58 	display: block;
   -1    59 	width: 100%;
   -1    60 	resize: vertical;
   -1    61 }

diff --git a/src/popup.html b/src/popup.html

@@ -5,6 +5,15 @@
    5     5 </head>
    6     6 <body>
    7     7 	<table></table>
   -1     8 
   -1     9 	<details class="raw-rules">
   -1    10 		<summary>Edit raw rules</summary>
   -1    11 		<form>
   -1    12 			<textarea rows="10"></textarea>
   -1    13 			<button>Save</button>
   -1    14 		</form>
   -1    15 	</details>
   -1    16 
    8    17 	<details>
    9    18 		<summary>Help</summary>
   10    19 		<p>In the table above, the columns represent different types of requests. The rows represent domains. Numbers show how many requests of a given type the current tab tries to make to the given domain. Red cells are blocked, green cells are allowed. Light green cells are allowed indirectly, e.g. because they represent a sub-domain of an allowed domain. Grey cells are disabled..</p>
@@ -15,6 +24,7 @@
   15    24 			<li><strong>sub-domains</strong>: If you allow a domain, all of its sub-domains are allowed along with it.</li>
   16    25 		</ul>
   17    26 	</details>
   -1    27 
   18    28 	<script src="shared.js"></script>
   19    29 	<script src="popup.js"></script>
   20    30 </body>

diff --git a/src/popup.js b/src/popup.js

@@ -5,6 +5,7 @@ var requests;
    5     5 var rules;
    6     6 
    7     7 var table = document.querySelector('table');
   -1     8 var rawRules = document.querySelector('.raw-rules');
    8     9 
    9    10 var sendMessage = function(type, data) {
   10    11     return browser.runtime.sendMessage({type: type, data: data});
@@ -149,6 +150,22 @@ var loadContext = function(c) {
  149   150 
  150   151 browser.webNavigation.onBeforeNavigate.addListener(window.close);
  151   152 
   -1   153 rawRules.addEventListener('toggle', () => {
   -1   154     if (rawRules.open) {
   -1   155         var textarea = rawRules.querySelector('textarea');
   -1   156         sendMessage('getAllRules').then(allRules => {
   -1   157             textarea.value = JSON.stringify(allRules, null, 2);
   -1   158         });
   -1   159     }
   -1   160 });
   -1   161 
   -1   162 rawRules.querySelector('form').addEventListener('submit', event => {
   -1   163     event.preventDefault();
   -1   164     var textarea = rawRules.querySelector('textarea');
   -1   165     var newRules = JSON.parse(textarea.value);
   -1   166     sendMessage('setAllRules', newRules).then(window.close);
   -1   167 });
   -1   168 
  152   169 document.addEventListener('DOMContentLoaded', () => {
  153   170     loadContext();
  154   171 });