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
4361df4ac95d5d37e67906fdda4411710566cadc
parent
c462a92fe3b3a214d59262eb90917f094dcc78d1
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2022-08-07 08:24
detect inline numbers

Diffstat

M README.md 2 --
M manifest.json 5 +++++
M src/bg.js 4 +++-
A src/content.js 17 +++++++++++++++++

4 files changed, 25 insertions, 3 deletions


diff --git a/README.md b/README.md

@@ -35,6 +35,4 @@ to allow only those requests you want. Definitely for advanced users.
   35    35 
   36    36 ## Known issues
   37    37 
   38    -1 -	there are no counts for inline code, so you cannot see whether they are
   39    -1 	relevant for the current page
   40    38 -	some cached requests are not included in the request counts

diff --git a/manifest.json b/manifest.json

@@ -16,6 +16,11 @@
   16    16   "background": {
   17    17     "scripts": ["src/shared.js", "src/bg.js"]
   18    18   },
   -1    19   "content_scripts": [{
   -1    20     "js": ["src/content.js"],
   -1    21     "matches": ["<all_urls>"],
   -1    22     "run_at": "document_start"
   -1    23   }],
   19    24   "permissions": [
   20    25     "storage",
   21    26     "tabs",

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

@@ -65,7 +65,7 @@ var getCurrentTab = function() {
   65    65     }).then(tabs => tabs[0]);
   66    66 };
   67    67 
   68    -1 browser.runtime.onMessage.addListener(msg => {
   -1    68 browser.runtime.onMessage.addListener((msg, sender) => {
   69    69     if (msg.type === 'get') {
   70    70         return getCurrentTab().then(tab => {
   71    71             var context = msg.data || getHostname(tab.url);
@@ -83,6 +83,8 @@ browser.runtime.onMessage.addListener(msg => {
   83    83             msg.data.value,
   84    84         );
   85    85         return Promise.resolve(restrictRules(msg.data.context));
   -1    86     } else if (msg.type === 'securitypolicyviolation') {
   -1    87         pushRequest(sender.tab.id, 'inline', msg.data);
   86    88     }
   87    89 });
   88    90 

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

@@ -0,0 +1,17 @@
   -1     1 /* global browser */
   -1     2 
   -1     3 const TYPE_MAP = {
   -1     4     'style-src': 'css',
   -1     5     'script-src': 'script',
   -1     6     'img-src': 'media',
   -1     7 };
   -1     8 
   -1     9 document.addEventListener('securitypolicyviolation', event => {
   -1    10     var type = TYPE_MAP[event.violatedDirective];
   -1    11     if (type) {
   -1    12         browser.runtime.sendMessage({
   -1    13             type: 'securitypolicyviolation',
   -1    14             data: type,
   -1    15         });
   -1    16     }
   -1    17 });