diff --git a/src/common/mainWorldOptionsWatcher/Client.js b/src/common/mainWorldOptionsWatcher/Client.js
new file mode 100644
index 0000000..3e5a9f9
--- /dev/null
+++ b/src/common/mainWorldOptionsWatcher/Client.js
@@ -0,0 +1,76 @@
+export const kDefaultTimeout = 10 * 1000;  // 10 seconds
+
+// Main World OptionsWatcher client (used in scripts injected into the Main
+// World (MW) to get the options).
+export default class MWOptionsWatcherClient {
+  constructor(options, CSTarget, MWTarget, timeout) {
+    if (!CSTarget || !MWTarget)
+      throw new Error(
+          `[MWOptionsWatcherClient] CSTarget and MWTarget are compulsory.`);
+
+    this.CSTarget = CSTarget;
+    this.MWTarget = MWTarget;
+    this.timeout = timeout ?? kDefaultTimeout;
+    this.#setUp(options);
+  }
+
+  #setUp(options) {
+    this.#sendRequestWithoutCallback('setUp', {options});
+  }
+
+  async getOption(option) {
+    if (!option) return null;
+    return this.#sendRequest('getOption', {option});
+  }
+
+  async getOptions(options) {
+    if (!options || options?.length === 0) return [];
+    return this.#sendRequest('getOptions', {options});
+  }
+
+  async isEnabled(option) {
+    if (!option) return null;
+    return this.#sendRequest('isEnabled', {option});
+  }
+
+  async areEnabled(options) {
+    if (!options || options?.length === 0) return [];
+    return this.#sendRequest('areEnabled', {options});
+  }
+
+  #sendRequestWithoutCallback(action, request, uuid) {
+    if (!uuid) uuid = self.crypto.randomUUID();
+    const data = {
+      target: this.CSTarget,
+      uuid,
+      action,
+      request,
+    };
+    window.postMessage(data, '*');
+  }
+
+  #sendRequest(action, request) {
+    return new Promise((res, rej) => {
+      const uuid = self.crypto.randomUUID();
+
+      let timeoutId;
+      let listener = e => {
+        if (e.source !== window || e.data?.target !== this.MWTarget ||
+            e.data?.uuid !== uuid)
+          return;
+
+        window.removeEventListener('message', listener);
+        clearTimeout(timeoutId);
+        res(e.data?.response);
+      };
+      window.addEventListener('message', listener);
+
+      timeoutId = setTimeout(() => {
+        window.removeEventListener('message', listener);
+        rej(new Error('Timed out while waiting response.'));
+      }, this.timeout);
+
+      this.#sendRequestWithoutCallback(action, request, uuid);
+    });
+  }
+}
diff --git a/src/common/mainWorldOptionsWatcher/Server.js b/src/common/mainWorldOptionsWatcher/Server.js
new file mode 100644
index 0000000..0d30aac
--- /dev/null
+++ b/src/common/mainWorldOptionsWatcher/Server.js
@@ -0,0 +1,91 @@
+import OptionsWatcher from '../../common/optionsWatcher.js';
+
+// Main World OptionsWatcher server (used in content scripts to be able to serve
+// the options to Main World (MW) scripts).
+export default class MWOptionsWatcherServer {
+  constructor(CSTarget, MWTarget) {
+    if (!CSTarget || !MWTarget)
+      throw new Error(
+          `[MWOptionsWatcherServer] CSTarget and MWTarget are compulsory.`);
+
+    this.optionsWatcher = null;
+    this.CSTarget = CSTarget;
+    this.MWTarget = MWTarget;
+
+    window.addEventListener('message', e => this.handleMessage(e));
+  }
+
+  handleMessage(e) {
+    const uuid = e.data?.uuid;
+    if (e.source !== window || e.data?.target !== this.CSTarget || !uuid)
+      return;
+
+    if (e.data?.action === 'setUp') {
+      this.optionsWatcher = new OptionsWatcher(e.data?.request?.options);
+      return;
+    }
+
+    if (!this.optionsWatcher) {
+      console.warn(`[MWOptionsWatcherServer] Action '${
+          e.data?.action}' called before setting up options watcher.`);
+      return;
+    }
+
+    switch (e.data?.action) {
+      case 'getOption':
+        this.optionsWatcher.getOption(e.data?.request?.option).then(value => {
+          this.respond(uuid, value);
+        });
+        return;
+
+      case 'getOptions':
+        var promises = [];
+        var options = e.data?.request?.options ?? [];
+        for (const option of options) {
+          promises.push(this.optionsWatcher.getOption(option));
+        }
+        Promise.all(promises).then(responses => {
+          const response = {};
+          for (let i = 0; i < responses.length; i++) {
+            response[options[i]] = responses[i];
+          }
+          this.respond(uuid, response);
+        });
+        return;
+
+      case 'isEnabled':
+        this.optionsWatcher.isEnabled(e.data?.request?.option).then(value => {
+          this.respond(uuid, value);
+        });
+        return;
+
+      case 'areEnabled':
+        var promises = [];
+        var options = e.data?.request?.options ?? [];
+        for (const option of options) {
+          promises.push(this.optionsWatcher.isEnabled(option));
+        }
+        Promise.all(promises).then(responses => {
+          const response = {};
+          for (let i = 0; i < responses.length; i++) {
+            response[options[i]] = responses[i];
+          }
+          this.respond(uuid, response);
+        });
+        return;
+
+      default:
+        console.error(`[MWOptionsWatcherServer] Invalid action received (${
+            e.data?.action})`);
+    }
+  }
+
+  respond(uuid, response) {
+    const data = {
+      target: this.MWTarget,
+      uuid,
+      response,
+    };
+    window.postMessage(data, window.origin);
+  }
+}
