Add XHR response modifier
- Add ResponseModifier class which is responsible for handling the
modification of the responses intercepted by XHRProxy. The
modifications occur by processing requests via several individual
response modifiers sequentially, which are applied if the URL matches
a RegEx condition and, if applicable, passes a condition based on the
features enabled by the user.
- A sample response modifier called "demo" is included, to show how a
simple modifier would work.
- Add mainWorldOptionsWatcher with 2 components: a server and a client,
so main world scripts (clients) can retrieve the extension options via
their corresponding content scripts (the servers) using an
OptionsWatcher class instantiated by the server. This is used by the
ResponseModifier class since it's injected into the main world because
it's the only way to intercept requests.
Bug: twpowertools:153
Change-Id: I8a9767e1eadd60d3a0f1054669e1e1f5e7a49fbb
diff --git a/src/contentScripts/communityConsole/start.js b/src/contentScripts/communityConsole/start.js
index a6e171d..f364626 100644
--- a/src/contentScripts/communityConsole/start.js
+++ b/src/contentScripts/communityConsole/start.js
@@ -1,5 +1,7 @@
import {injectScript, injectStylesheet} from '../../common/contentScriptsUtils.js';
+import MWOptionsWatcherServer from '../../common/mainWorldOptionsWatcher/Server.js';
import {getOptions} from '../../common/optionsUtils.js';
+import {kCSTarget, kMWTarget} from '../../xhrInterceptor/responseModifiers/index.js';
import AutoRefresh from './autoRefresh.js';
import ExtraInfo from './extraInfo.js';
@@ -74,4 +76,6 @@
injectStylesheet(chrome.runtime.getURL('css/ui_spacing/shared.css'));
injectStylesheet(chrome.runtime.getURL('css/ui_spacing/console.css'));
}
+
+ new MWOptionsWatcherServer(kCSTarget, kMWTarget);
});