main 5a29d0efe0bb cached
53 files
258.2 KB
64.8k tokens
176 symbols
1 requests
Download .txt
Showing preview only (275K chars total). Download the full file or copy to clipboard to get everything.
Repository: privacy-tech-lab/gpc-optmeowt
Branch: main
Commit: 5a29d0efe0bb
Files: 53
Total size: 258.2 KB

Directory structure:
gitextract_4uj713gw/

├── .github/
│   └── workflows/
│       └── node.js.yml
├── .gitignore
├── FUNDING.yml
├── LICENSE.md
├── README.md
├── README_ARCHITECTURE.md
├── package.json
├── src/
│   ├── assets/
│   │   └── icon.psd
│   ├── background/
│   │   ├── control.js
│   │   ├── protection/
│   │   │   ├── background.js
│   │   │   ├── listeners-chrome.js
│   │   │   ├── listeners-firefox.js
│   │   │   ├── protection-ff.js
│   │   │   └── protection.js
│   │   └── storage.js
│   ├── common/
│   │   ├── editDomainlist.js
│   │   ├── editRules.js
│   │   └── settings.js
│   ├── content-scripts/
│   │   ├── contentScript.js
│   │   ├── injection/
│   │   │   └── gpc-dom.js
│   │   └── registration/
│   │       └── gpc-dom.js
│   ├── data/
│   │   ├── complianceData.js
│   │   ├── defaultSettings.js
│   │   └── headers.js
│   ├── manifests/
│   │   ├── chrome/
│   │   │   ├── manifest-dev.json
│   │   │   └── manifest-dist.json
│   │   └── firefox/
│   │       ├── manifest-dev.json
│   │       └── manifest-dist.json
│   ├── options/
│   │   ├── components/
│   │   │   ├── scaffold-component.html
│   │   │   └── util.js
│   │   ├── dark-mode.css
│   │   ├── options.html
│   │   ├── options.js
│   │   ├── styles.css
│   │   └── views/
│   │       ├── about-view/
│   │       │   ├── about-view.html
│   │       │   └── about-view.js
│   │       ├── domainlist-view/
│   │       │   ├── domainlist-view.html
│   │       │   └── domainlist-view.js
│   │       ├── main-view/
│   │       │   ├── main-view.html
│   │       │   └── main-view.js
│   │       └── settings-view/
│   │           ├── settings-view.html
│   │           └── settings-view.js
│   ├── popup/
│   │   ├── popup.html
│   │   ├── popup.js
│   │   └── styles.css
│   ├── rules/
│   │   ├── gpc_exceptions_rules.json
│   │   └── universal_gpc_rules.json
│   └── theme/
│       └── darkmode.js
├── test/
│   └── background/
│       ├── cookieRemoval.test.js
│       └── gpc.test.js
├── ui-mockup/
│   ├── Mockup v1.0.xd
│   └── Popup designs/
│       └── Popup.xd
└── webpack.config.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/node.js.yml
================================================
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Tests

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x, 18.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: npm ci
    - run: npm test


================================================
FILE: .gitignore
================================================
# Local user files
.DS_Store
.idea
.vscode

# Node.js
node_modules

# Distribution files
dist
dev

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*


================================================
FILE: FUNDING.yml
================================================
github: privacy-tech-lab


================================================
FILE: LICENSE.md
================================================
MIT License

Copyright (c) 2021 privacy-tech-lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
<p align="center">
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/releases"><img alt="GitHub release (latest by date)" src="https://img.shields.io/github/v/release/privacy-tech-lab/gpc-optmeowt"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/releases"><img alt="GitHub Release Date" src="https://img.shields.io/github/release-date/privacy-tech-lab/gpc-optmeowt"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/commits/main"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/privacy-tech-lab/gpc-optmeowt"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/actions/workflows/node.js.yml"><img alt="GitHub Actions" src="https://github.com/privacy-tech-lab/gpc-optmeowt/actions/workflows/node.js.yml/badge.svg?branch=main"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/issues"><img alt="GitHub issues" src="https://img.shields.io/github/issues-raw/privacy-tech-lab/gpc-optmeowt"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/issues?q=is%3Aissue+is%3Aclosed"><img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed-raw/privacy-tech-lab/gpc-optmeowt"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md"><img alt="GitHub" src="https://img.shields.io/github/license/privacy-tech-lab/gpc-optmeowt"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/watchers"><img alt="GitHub watchers" src="https://img.shields.io/github/watchers/privacy-tech-lab/gpc-optmeowt?style=social"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/stargazers"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/privacy-tech-lab/gpc-optmeowt?style=social"></a>
  <a href="https://github.com/privacy-tech-lab/gpc-optmeowt/network/members"><img alt="GitHub forks" src="https://img.shields.io/github/forks/privacy-tech-lab/gpc-optmeowt?style=social"></a>
  <a href="https://github.com/sponsors/privacy-tech-lab"><img alt="GitHub sponsors" src="https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86"></a>
</p>
  
<br>

<p align="center">
  <a href="https://privacytechlab.org/"><img src="https://github.com/privacy-tech-lab/gpc-optmeowt/blob/issue-19/src/assets/cat-w-text/optmeow-logo-circle.png" width="150px" height="150px" alt="OptMeowt logo"></a>
</p>

# OptMeowt 🐾

OptMeowt ("Opt Me Out") is a browser extension for opting you out from web tracking. OptMeowt works by sending Global Privacy Control (GPC) signals to visited websites per the [GPC spec](https://privacycg.github.io/gpc-spec/) that we are developing [at the W3C](https://github.com/privacycg/gpc-spec). In addition, OptMeowt also opts you out from Google's Topics API.

<p align="center">
  <a href="https://addons.mozilla.org/en-US/firefox/addon/optmeowt/"><img src="https://github.com/privacy-tech-lab/optmeowt/blob/main/firefox-add-ons-badge.png" width="172px" alt="Firefox Add Ons badge"></a>
  <a href="https://chrome.google.com/webstore/detail/optmeowt/hdbnkdbhglahihjdbodmfefogcjbpgbo"><img src="https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/chrome-web-store-badge.png" width="200px" alt="Chrome Web Store badge"></a>
<p>

OptMeowt is developed and maintained by Ambrose Vannier (@avan36), Ruby Friedman (@RubyFri), Matthew Rich (@mcrich921), Austin Bosch (@Spongebosch) and Sebastian Zimmeck (@SebastianZimmeck) of the [privacy-tech-lab](https://privacytechlab.org/).

Former contributors are Francisca Wijaya (@franciscawijaya), Sage Altman (@sagealtman), Matt May (@Mattm27), Ebuka Akubilo (@eakubilo), Samir Cerrato (@samir-cerrato), Nate Levinson (@natelevinson10), Oliver Wang (@OliverWang13), Sophie Eng (@sophieeng), Kate Hausladen (@katehausladen), Jocelyn Wang (@Jocelyn0830), Kuba Alicki (@kalicki1), Stanley Markman (@stanleymarkman), Kiryl Beliauski (@kbeliauski), Daniel Knopf (@dknopf) and Abdallah Salia (@asalia-1).

[1. Research Publications](#1-research-publications)  
[2. Promo Video](#2-promo-video)  
[3. How Does OptMeowt Work?](#3-how-does-optmeowt-work)  
[4. Installing OptMeowt from Source](#4-installing-optmeowt-from-source)  
[5. Installing OptMeowt for Developers](#5-installing-optmeowt-for-developers)  
[6. Installing the OptMeowt PETS 2023 Version](#6-installing-the-optmeowt-pets-2023-version)  
[7. Testing](#7-testing)  
[8. OptMeowt's Permission Use](#8-optmeowts-permission-use)  
[9. OptMeowt's Architecture](#9-optmeowts-architecture)  
[10. Directories in this Repo](#10-directories-in-this-repo)  
[11. Third Party Libraries](#11-third-party-libraries)  
[12. Developer Guide](#12-developer-guide)  
[13. Thank You!](#13-thank-you)

## 1. Research Publications

- Sebastian Zimmeck, [Remarks on the Relevance of Privacy Expectations for Default Opt-out Settings](https://sebastianzimmeck.de/zimmeckEtAlRemarks2026.pdf), IEEE Symposium on Privacy Expectations (ISoPE), New York, New York, 2026, [BibTeX](https://sebastianzimmeck.de/citations.html#zimmeckEtAlGPCRemarks2026Bibtex).
- Sebastian Zimmeck, Nishant Aggarwal, Zachary Liu, Sage Altman and Konrad Kollnig, [Exercising the CCPA Opt-out Right on Android: Legally Mandated but Practically Challenging](https://sebastianzimmeck.de/zimmeckEtAlGPCAndroid2026.pdf), 26th Privacy Enhancing Technologies Symposium (PETS), Calgary, Canada, July 2026, [BibTeX](https://sebastianzimmeck.de/citations.html#zimmeckEtAlGPCAndroid2026Bibtex)
- Katherine Hausladen, Oliver Wang, Sophie Eng, Jocelyn Wang, Francisca Wijaya, Matt May and Sebastian Zimmeck, [Websites' Global Privacy Control Compliance at Scale and over Time](https://sebastianzimmeck.de/hausladenEtAlGPCWeb2025.pdf), 34th USENIX Security Symposium (USENIX Security), Seattle, CA, August 2025, [BibTeX](https://sebastianzimmeck.de/citations.html#hausladenEtAlGPCWeb2025Bibtex)
- Francisca Wijaya, Katherine Hausladen, Matt May, Oliver Wang, Sophie Eng and Sebastian Zimmeck, [Crawl for GPC: An Investigation of CCPA Compliance on the Internet](https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/research/wijayaEtAlCrawlForGPC2024Poster.pdf), Summer Research 2024 Poster Session, Wesleyan University, July 2024
- Sebastian Zimmeck, Nishant Aggarwal, Zachary Liu and Konrad Kollnig, [From Ad Identifiers to Global Privacy Control: The Status Quo and Future of Opting Out of Ad Tracking on Android](https://arxiv.org/abs/2407.14938), Under Review
- Sebastian Zimmeck, Eliza Kuller, Chunyue Ma, Bella Tassone and Joe Champeau, [Generalizable Active Privacy Choice: Designing a Graphical User Interface for Global Privacy Control](https://sebastianzimmeck.de/zimmeckEtAlGPC2024.pdf), 24th Privacy Enhancing Technologies Symposium (PETS), Bristol, UK and Online Event, July 2024, [BibTeX](https://sebastianzimmeck.de/citations.html#zimmeckEtAlGPC2024Bibtex)
- Katherine Hausladen, [Investigating the Current State of CCPA Compliance on the Internet](https://doi.org/10.14418/wes01.2.451), Master's Thesis, Wesleyan University, May 2024
- Nishant Aggarwal, Wesley Tan, Konrad Kollnig and Sebastian Zimmeck, [The Invisible Threat: Exploring Mobile Privacy Concerns](https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/research/aggarwalEtAlInvisibleThreat2023Poster.pdf), Summer Research 2023 Poster Session, Wesleyan University, July 2023
- Eliza Kuller, [Privacy Choice Mechanisms and Online Advertising: Can Generalizable Active Privacy Choices and Online Advertising Coexist?](https://doi.org/10.14418/wes01.1.2797), Undergraduate Honors Thesis, Wesleyan University, April 2023
- Sebastian Zimmeck, Oliver Wang, Kuba Alicki, Jocelyn Wang and Sophie Eng, [Usability and Enforceability of Global Privacy Control](https://sebastianzimmeck.de/zimmeckEtAlGPC2023.pdf), 23rd Privacy Enhancing Technologies Symposium (PETS)
  Lausanne, Switzerland and Online Event, July 2023, [BibTeX](https://sebastianzimmeck.de/citations.html#zimmeckEtAlGPC2023Bibtex). For installing the OptMeowt version used in this paper, see the [instructions below](https://github.com/privacy-tech-lab/gpc-optmeowt#6-installing-the-optmeowt-pets-2023-version).
- Isabella Tassone, Chunyue Ma, Eliza Kuller, Joe Champeau and Sebastian Zimmeck, [Enhancing Online Privacy: The Development of Practical Privacy Choice Mechanisms](https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/research/tassoneEtAlEnhancingOnlinePrivacy2022Poster.pdf), Summer Research 2022 Poster Session, Wesleyan University, July 2022
- Sebastian Zimmeck, [Improving Internet Privacy with Global Privacy Control (GPC)](https://sebastianzimmeck.de/SaTC_PI_Meeting_2022_Poster_GPC_Zimmeck.pdf), 5th NSF Secure and Trustworthy Cyberspace Principal Investigator Meeting (2022 SaTC PI Meeting), Arlington, Virginia, USA, June 2022
- Kuba Alicki, [Don't Sell Our Data: Exploring CCPA Compliance via Automated Privacy Signal Detection](https://digitalcollections.wesleyan.edu/islandora/dont-sell-our-data-exploring-ccpa-compliance-automated-privacy-signal-detection), Undergraduate Honors Thesis, Wesleyan University, April 2022
- Eliza Kuller, Chunyue Ma, Isabella Tassone and Sebastian Zimmeck, [Making Online Privacy Choice Mechanisms Effective and Usable](http://summer21.research.wesleyan.edu/2021/07/22/balancing-usability-and-active-choice-while-developing-privacy-permission-schemes/), Summer Research 2021 Poster Session, Wesleyan University, Online, July 2021
- Sebastian Zimmeck and Kuba Alicki, [Standardizing and Implementing Do Not Sell (Short Paper)](https://sebastianzimmeck.de/zimmeckAndAlicki2020DoNotSell.pdf), 19th Workshop on Privacy in the Electronic Society (WPES), Online Event, November 2020, [BibTeX](https://sebastianzimmeck.de/citations.html#zimmeckAndAlicki2020DoNotSellBibtex)

## 2. Promo Video

[![Watch the Video](https://privacytechlab.org/static/images/OptMeowt_Movie.png)](https://drive.google.com/file/d/1eto77EV13WazpJN1hGXiKKsP2l7oMEu1/view?usp=share_link)

## 3. How Does OptMeowt Work?

OptMeowt sends GPC signals to websites when you browse the web. Such signals must be respected for California consumers per the California Consumer Privacy Act (CCPA), [Regs Section 999.315(d)](https://oag.ca.gov/sites/all/files/agweb/pdfs/privacy/oal-sub-final-text-of-regs.pdf). The number of jurisdictions that require websites to respect GPC signals is increasing. Some websites also respect them even if they are not required to do so.

In detail, OptMeowt uses the following methods to opt you out:

1. The [GPC header and JS property](https://privacycg.github.io/gpc-spec/).
2. A `Permissions-Policy` header that opts sites out of Google's [Topics API](https://developer.mozilla.org/en-US/docs/Web/API/Topics_API) on Chromium-based browsers.

**Opting Out of the Topics API:** As all browser vendors are phasing out the use of third-party cookies. In this context Google introduced the [Topics API](https://developer.mozilla.org/en-US/docs/Web/API/Topics_API). The Topics API identifies users' general areas of interest which are then used for personalized advertising. These topics are generated through observing and recording a users' browsing activity. Websites will then receive access to these topics that are stored on users' browsers. To opt you out of the Topics API OptMeowt sends a `Permissions-Policy` header to all the sites you visit. This approach follows [Google's documentation](https://developer.chrome.com/en/docs/privacy-sandbox/topics/#site-opt-out) on how to opt a site out of the Topics API. Note that this functionality of OptMeowt is only available for Chromium browsers as other browsers do not implement the Topics API.

**Customizing which sites receive GPC signals:** For every site you visit OptMeowt will automatically add its domain to the `domain list`. Each newly added domain will receive GPC signals by default. However, you can exclude domains that should not receive GPC signals. This functionality is available on OptMeowt's popup window and settings page.

For a more in-depth look at how OptMeowt works, check out our [Beginners Guide to OptMeowt](https://docs.google.com/document/d/1H0sA6hK0Q0OLT4Tz_Yp-byHi0U4Ue5DO8k7K-NXnY2Q/edit?usp=sharing). (The document is up to date as of its date. Later changes to OptMeowt are not reflected.)

## 4. Installing OptMeowt from Source

Here are the instructions for installing OptMeowt from the source files in this repo.

### Chrome and Firefox

1. Clone this repo locally with:

   ```bash
   git clone https://github.com/privacy-tech-lab/gpc-optmeowt.git
   ```

   You can also download a zipped copy and unzip it.

2. Install [Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
3. From within your local `/gpc-optmeowt/` directory install OptMeowt's dependencies with:

   ```bash
   npm ci
   ```

4. Build the project by running:

   ```bash
   npm run build
   ```

   This command will create a built for both Chrome and Firefox in `.../gpc-optmeowt/dist/chrome/` and `.../gpc-optmeowt/dist/firefox/`, respectively. `npm run build` will also create packaged versions of OptMeowt in `.../gpc-optmeowt/packages` for distribution on the Chrome Web Store and on Firefox Add-Ons.

### Chrome

5. In Chrome, navigate to the extensions page at `chrome://extensions/`.
6. Enable `Developer mode` with the slider on the top right corner of the extension page.
7. Click the `Load unpacked` button in the top left of the page.
8. Select the directory where you built OptMeowt, by default `/gpc-optmeowt/dist/chrome/` (the directory that contains the `manifest.json`).

### Firefox

5. In Firefox, navigate to the addons page with developer privileges at `about:debugging#/runtime/this-firefox`.
6. Under `Temporary extensions`, click `Load Temporary Add-on...`.
7. Select the manifest from the directory where you built OptMeowt, by default `/gpc-optmeowt/dist/firefox/manifest.json/`.

**Note**: OptMeowt is in active development and new features are being added, some of which may cause errors. You can always get the stable release version on the [Chrome Web Store](https://chrome.google.com/webstore/detail/optmeowt/hdbnkdbhglahihjdbodmfefogcjbpgbo) and on [Firefox Add-Ons](https://addons.mozilla.org/en-US/firefox/addon/optmeowt/). You can also disable sending GPC signals to a site in case OptMeowt causes it to break.

## 5. Installing OptMeowt for Developers

To build the development versions of OptMeowt follow the directions above but replace `npm run build` with:

```bash
npm run start
```

This command will run the npm script (referenced in `package.json`) that will call Webpack in development mode (Webpack settings are in `webpack.config.js`). `npm run start` will also initiate Webpack servers for both the Firefox and Chrome versions, which will listen for changes as you work and rebuild as necessary.

### 5.1 Webpack

Webpack will build the development versions of OptMeowt into the `dev` subdirectory instead of the `dist` subdirectory. The subdirectories for Chrome and Firefox are `dev/chrome` and `dev/firefox`, respectively.

Also, when you build for development, the development manifest (in `src/manifest-dev.json`) will be used instead of the distribution manifest (in `src/manifest-dist.json`). The development manifest contains an unsafe eval that we use for our source maps during development. The distribution manifest does not contain this eval. Webpack will select the correct manifest depending on whether you build for development or distribution.

To include new dependencies you can run:

```bash
npm install
```

Running this command instead of `npm ci` will include new dependencies in the `package-lock.json`, which is generated from the `package.json`.

### 5.2 Debugging

We like to use the [Debugger for Firefox](https://marketplace.visualstudio.com/items?itemName=firefox-devtools.vscode-firefox-debug) from within [Visual Studio Code](https://code.visualstudio.com/) when in development to help automating the development and build processes. The default behavior is `F5` to launch and load the extension in the browser. There is a similar extension that you can use for Chrome, [JavaScript Debugger](https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug), which is already included in Visual Studio Code by default. Make sure to follow the online documentation on writing the correct `.vscode/launch.json` file, or other necessary settings files, in order to properly load OptMeowt with the debugger.

### 5.3 Developing on Windows

We have built most of our codebase in macOS, so path variables and similar code may cause the build to break in other OSs, in particular Windows. We recommend using macOS or installing a Linux OS if you will be working with the codebase in any significant manner.

## 6. Installing the OptMeowt PETS 2023 Version

The version of OptMeowt used in our 2023 PETS paper, [Usability and Enforceability of Global Privacy Control](https://sebastianzimmeck.de/zimmeckEtAlGPC2023.pdf), can be found in our [v3.0.0-paper release](https://github.com/privacy-tech-lab/gpc-optmeowt/releases/tag/v3.0.0-paper). To view the v3.0.0-paper code, you can [look at the repo here](https://github.com/privacy-tech-lab/gpc-optmeowt/tree/v3.0.0-paper). Instructions for building the extension locally are the same as stated above per our [Firefox instructions](https://github.com/privacy-tech-lab/gpc-optmeowt/tree/main#firefox). To activate Analysis mode in the v3.0.0-paper release press the `Protection Mode` label in the popup. In addition, Analysis mode requires other privacy extensions or browsers to be disabled. For further detailed information on how to use analysis mode, please refer to [our methodology](https://github.com/privacy-tech-lab/gpc-optmeowt/tree/v4.0.1/#4-analysis-mode-firefox-only).

Analysis mode used to be part of the OptMeowt extension but is now part of the [GPC Web Crawler](https://github.com/privacy-tech-lab/gpc-web-crawler), which you can use to analyze websites' GPC compliance at scale.

## 7. Testing

OptMeowt uses the [Mocha](https://mochajs.org/) framework as well as [Puppeteer](https://pptr.dev/) to execute its testing and continuous integration. The continuous integration is built into the OptMeowt repo with Github Actions. The [Actions tab](https://github.com/privacy-tech-lab/gpc-optmeowt/actions) shows all workflows and past unit test checks for previous PRs.

The test responsible for checking OptMeowt's ability to set the GPC signal can not be run with GitHub Actions. You can run it locally with:

```bash
npm test
```

Using Puppeteer this command will launch an automated headful browser on Chromium testing the Chrome GPC signal against the [GPC reference server](https://global-privacy-control.vercel.app/).

### 7.1 Running Automated Unit Tests

**Locally:**
You can run unit tests locally.

1. Clone this repo locally or download a zipped copy and unzip it.
2. Make sure npm is up to date by running `npm -v` to check the version and updating follow [the instructions on the npm site](https://docs.npmjs.com/try-the-latest-stable-version-of-npm), depending on your operating system.
3. Run tests with:

   ```bash
   npm test
   ```

4. If Puppeteer is not installed, run:

   ```bash
   npm install
   ```

**Continuous Integration:**
The continuous integration is built into the OptMeowt repo. Therefore, no changes to the extension environment are needed to run new tests.

### 7.2 Manual UI testing

The following procedure is for testing the OptMeowt extension UI, which cannot be automated. They are recommended to be performed manually as follows:

1. Download the version of the extension you want to test through `npm run start`. Then, download the unpacked dev version for your browser.
2. Navigate to a site with the well-known file, like <https://global-privacy-control.vercel.app/>
3. Click on the OptMeowt symbol in the top right of your browser.
   - [ ] TEST 1: The symbol for the cat should be solid green.
   - [ ] TEST 2: The URL of the website should be written under the "Protection Mode" banner.
   - [ ] TEST 3: Global Privacy Control should be enabled.
   - [ ] TEST 4: There should be a blue number detailing the number of domains receiving signals.
4. Click on the drop down for "3rd Party Domains".
   - [ ] TEST 5: There should be sites that show up with Global Privacy Control switched on.
5. Navigate out of the "3rd Party Domains" drop down and click on the "Website Response" drop down
   - [ ] TEST 6: There should be text showing that GPC Signals were accepted.
   - [ ] TEST 7: Switch "Dark Mode" on and off and ensure the popup is correctly changing colors.
6. Navigate to the top of the popup and click on the "More" symbol (image: Sliders) to go to the Settings page.
7. In the main settings page, click on "Disable" and open the popup.
   - [ ] TEST 8: The popup should be fully grayed out and showing the popup disabled.
8. In the website, move to the Domainlist page.
   - [ ] TEST 9: There should be multiple domains showing in the Domainlist tab.
9. Go back to the main settings page and export Domainlist.
   - [ ] TEST 10: Check the exported Domainlist and the Domainlist in the settings page to make sure the websites match up.

### 7.3 Creating a New Test

1. Navigate to `.../gpc-optmeowt/test/`. Then navigate to the folder in the test directory that corresponds to the tested function's location in the extension source code.
2. Create a new file in the matching folder. Name the file with the format `FUNCTION_NAME.test.js`.
   For example, if testing a function named `sum` located in the folder `.../src/math`, create the test called `sum.test.js` in the folder `.../test/math`
3. Write test using [ECMAScript formatting](https://nodejs.org/api/esm.html).

## 8. OptMeowt's Permission Use

**Note**: We do not collect any data from you. Third parties will also not receive your data. The permissions OptMeowt is using are required for opting you out. To that end, OptMeowt uses the following permissions:

```json
"permissions": [
    "declarativeNetRequest",
    "webRequest",
    "webRequestBlocking",
    "webNavigation",
    "<all_urls>",
    "storage",
    "activeTab",
    "tabs",
    "scripting"
  ]
```

- `declarativeNetRequest`: Allows OptMeowt to modify rules, allowing us to send the GPC header
- `webRequest`: Pauses outgoing HTTP requests to append opt out headers
- `webRequestBlocking`: Allows an extension to intercept and potentially block, modify, or redirect web requests before they are completed
- `webNavigation`: Similar to `webRequest`, allows OptMeowt to check when navigation requests are made to reset processes
- `<all_urls>`: Gives OptMeowt permission to access and interact with the content and data of any website visited by the browser
- `storage`: Allows OptMeowt to save your opt out preferences in your browser
- `activeTab`: Allows OptMeowt to set opt out signals on your active browser tab
- `tabs`: Allows OptMeowt to keep track of HTTP headers per tab to show you the opt out status of the current site in a popup
- `scripting`: Allows OptMeowt to declare content scripts and send the GPC DOM signal

## 9. OptMeowt's Architecture

Detailed information on OptMeowt's architecture is available in a [separate readme](https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/README_ARCHITECTURE.md).

**Note**: The architecture readme is only current as of its commit date.

## 10. Directories in this Repo

Here are the main directories in this repo:

- `src/`: Main contents of the OptMeowt browser extension.
- `src/assets`: Graphical elements of the extension, including logos and button images.
- `src/background`: Listeners for events and logic for sending privacy signals.
- `src/data`: Definitions of headers and privacy flags.
- `src/options`: UI elements and scripts for the supplemental options page.
- `src/popup`: UI elements and scripts for the popup inside the extensions bar.
- `src/theme`: Dark and light mode themes.
- `ui-mockup`: Contains PDF and XD files demonstrating the preliminary mockup of OptMeowt.

## 11. Third Party Libraries

OptMeowt uses various [third party libraries](https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/package.json). We thank the developers.

## 12. Developer Guide

If you have questions about OptMeowt's functionality or have found a bug, please check out our [FAQ \ Known quirks](https://github.com/privacy-tech-lab/gpc-optmeowt/wiki/FAQ-%5C-Known-quirks) page on the [Wiki](https://github.com/privacy-tech-lab/gpc-optmeowt/wiki). If you cannot find what you are looking for, feel free to open an issue, and we will address it.

**Note**: When viewing your browser's console on a site, a 404 error status code regarding the domain's GPC status file (`/.well-known/gpc.json`) may be shown. This behavior is normal and will occur (1) on domains that do not support GPC and (2) on domains that support GPC but do not host a `/.well-known/gpc.json` file.

## 13. Thank You!

<p align="center"><strong>We would like to thank our supporters!</strong></p><br>

<p align="center">Major financial support provided by the National Science Foundation.</p>

<p align="center">
  <a href="https://nsf.gov/awardsearch/showAward?AWD_ID=2055196">
    <img class="img-fluid" src="./nsf.png" height="100px" alt="National Science Foundation Logo">
  </a>
</p>

<p align="center">Additional financial support provided by the Alfred P. Sloan Foundation, Wesleyan University, and the Anil Fernando Endowment.</p>

<p align="center">
  <a href="https://sloan.org/grant-detail/9631">
    <img class="img-fluid" src="./sloan_logo.jpg" height="70px" alt="Sloan Foundation Logo">
  </a>
  <a href="https://www.wesleyan.edu/mathcs/cs/index.html">
    <img class="img-fluid" src="./wesleyan_shield.png" height="70px" alt="Wesleyan University Logo">
  </a>
</p>

<p align="center">Conclusions reached or positions taken are our own and not necessarily those of our financial supporters, its trustees, officers, or staff.</p>

##

<p align="center">
  <a href="https://privacytechlab.org/"><img src="./plt_logo.png" width="200px" height="200px" alt="privacy-tech-lab logo"></a>
<p>


================================================
FILE: README_ARCHITECTURE.md
================================================
# Architecture Overview

```txt
src
├── assets       # Static images & files
├── background      # Manages the background script processes
│   ├── protection
│   │   ├── background.js
│   │   ├── listeners-chrome.js
│   │   ├── listeners-firefox.js
│   │   ├── protection-ff.js
│   │   └── protection.js
│   ├── control.js
│   └── storage.js
├── common       # Manages header sending and rules
│   ├── editDomainlist.js
│   └── editRules.js
├── content-scripts     # Runs processes on site on adds DOM signal
│   ├── injection
│   │   └── gpc-dom.js
│   ├── registration
│   │   └── gpc-dom.js
│   └── contentScript.js
├── data       # Stores constant data (DNS signals, settings, etc.)
│   ├── defaultSettings.js
│   ├── headers.js
│   └── regex.js
├── manifests      # Stores manifests
│   ├── chrome
│   │   ├── manifest-dev.json
│   │   └── manifest-dist.json
│   ├── firefox
│   │   ├── manifest-dev.json
│   │   └── manifest-dist.json
├── options       # Options page frontend
│   ├── components
│   │   ├── scaffold-component.html
│   │   └── util.js
│   ├── views
│   │   ├── about-view
│   │   │   ├── about-view.html
│   │   │   └── about-view.js
│   │   ├── domainlist-view
│   │   │   ├── domainlist-view.html
│   │   │   └── domainlist-view.js
│   │   ├── main-view
│   │   │   ├── main-view.html
│   │   │   └── main-view.js
│   │   └── settings-view
│   │       ├── settings-view.html
│   │       └── settings-view.js
│   ├── dark-mode.css
│   ├── options.html
│   ├── options.js
│   └── styles.css
├── popup       # Popup page frontend
│   ├── popup.html
│   ├── popup.js
│   └── styles.css
├── rules       # Manages universal rules
│   ├── gpc_exceptions_rules.json
│   └── universal_gpc_rules.json
└── theme       # Contains darkmode
    └── darkmode.js
test
└── background
    └── gpc.test.js
```

The following source folders have detailed descriptions further in the document.

[background](#background)\
[common](#common)\
[content-scripts](#content-scripts)\
[data](#data)\
[manifests](#manifests)\
[options](#options)\
[popup](#popup)\
[rules](#rules)\
[theme](#theme)

## background

1. `protection`
2. `control.js`
3. `storage.js`

### `src/background/protection`

1. `background.js`
2. `listeners-chrome.js`
3. `listeners-firefox.js`
4. `protection.js`
5. `protection-ff.js`

#### `protection/background.js`

Initializes the protection mode listeners.

#### `protection/listeners-chrome.js` and `protection/listeners-firefox.js`

Creates listeners for Chrome and Firefox, respectively.

#### `protection/protection.js`

Manages the domain list with functions like `logData();`, `updateDomainlistAndSignal();`, `pullToDomainlistCache();`, `syncDomainlists();`. Also responsible for supplying the popup with the proper information with `dataToPopup();`. Also creates listeners to watch the popup for domain list changes.

#### `protection/protection-ff.js`

Manages the domain list for Firefox.

### `background/control.js`

Uses `protection.js` to turn the extension on and off.

### `background/storage.js`

Handles storage uploads and downloads.

## common

1. `editDomainlist.js`
2. `editRules.js`

This folder holds common internal API's to be used throughout the extension.

### `common/editDomainlist.js`

Is an internal API to be used for editing a users domain list.

### `common/editRules.js`

Is an internal API to be used for editing rules that allow us to send the GPC header.

## content-scripts

1. `injection`
2. `registration`
3. `contentScript.js`

This folder contains our main content script and methods for injecting the GPC signal into the DOM.

### `src/content-scripts/injection`

1. `gpc-dom.js`

`gpc-dom.js` injects the DOM signal.

### `src/content-scripts/registration`

1. `gpc-dom.js`

This file injects `injection/gpc-dom.js` into the page using a static script. (Based on [this stack overflow thread](https://stackoverflow.com/questions/9515704/use-a-content-script-to-access-the-page-context-variables-and-functions))

### `content-scripts/contentScript.js`

This runs on every page and sends information to signal background processes.

## data

1. `defaultSettings.js`
2. `headers.js`
3. `regex.js`

This folder contains static data.

### `data/defaultSettings.js`

Contains the default OptMeowt settings.

### `data/headers.js`

Contains the default headers to be attached to online requests.

### `data/regex.js`

Contains regular expressions for finding "do not sell" links and related privacy signals.

## manifests

1. `chrome`
2. `firefox`

Contains the extension manifests

### `manifests/chrome`

1. `manifest-dev.json`
2. `manifest-dist.json`

Contains the development and distribution manifests for Chrome

### `manifests/firefox`

1. `manifest-dev.json`
2. `manifest-dist.json`

Contains the development and distribution manifests for Firefox

## options

1. `components`
2. `views`
3. `dark-mode.css`
4. `options.html`

This folder contains all of the frontend code

### `options/components`

1. `scaffold-component.html`
2. `util.js`

This folder contains the basic layout of every options page and helper functions to help render the pages.

### `options/views`

1. `about-view`
2. `domainlist-view`
3. `main-view`
4. `settings-view`

Contains all frontend and implementation of the settings pages.

#### `views/about-view`

1. `about-view.html`
2. `about-view.js`

Builds the "about" page

#### `views/domainlist-view`

1. `domainlist-view.html`
2. `domainlist-view.js`

Builds the domain list page

#### `views/main-view`

1. `main-view.html`
2. `main-view.js`

Builds the main options page

#### `views/settings-view`

1. `settings-view.html`
2. `settings-view.js`

Builds the settings page

### `options/dark-mode.css`

Contains the dark-mode styles for OptMeowt.

### `options/options.html` and `options/options.js`

Is the entry point for the main options page.

### `options/styles.css`

Contains the basic styles for OptMeowt.

## popup

1. `popup.html`
2. `popup.js`
3. `styles.css`

Contains the frontend and implementation for the OptMeowt popup.

## rules

1. `gpc_exception_rules.json`
2. `universal_gpc_rules.json`

Contains rule framework for sending GPC headers to sites.

## theme

1. `darkmode.js`

Contains the dark mode functionality.

**Links to APIs:**

Chrome: [webRequest](https://developer.chrome.com/docs/extensions/reference/webRequest/) and [webNavigation](https://developer.chrome.com/docs/extensions/reference/webNavigation/)

Firefox: [webRequest](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest) and [webNavigation](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation)


================================================
FILE: package.json
================================================
{
  "name": "optmeowt",
  "version": "6.1.0",
  "description": "A privacy extension that allows users to exercise rights under GPC",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "prestart": "rimraf dev",
    "start": "concurrently -k npm:start:firefox  npm:start:chrome",
    "start:firefox": "webpack --watch --mode development --env firefox",
    "start:chrome": "webpack --watch --mode development --env chrome",
    "prebuild": "rimraf dist && mkdir dist && mkdir dist/packages",
    "build": "npm run build:firefox && npm run build:chrome",
    "build:firefox": "webpack --mode production --env firefox",
    "build:chrome": "webpack --mode production --env chrome",
    "postbuild:firefox": "cd dist/firefox && zip -rFSX ../packages/ff-optmeowt-$npm_package_version.zip * -x '*.git*' -x '*.DS_Store*' -x '*.txt*'",
    "postbuild:chrome": "cd dist/chrome && zip -rFSX ../packages/chrome-optmeowt-$npm_package_version.zip * -x '*.git*' -x '*.DS_Store*' -x '*.txt*'",
    "test": "mocha $(find test -name '*.js')"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/privacy-tech-lab/gpc-optmeowt.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/privacy-tech-lab/gpc-optmeowt/issues"
  },
  "homepage": "https://github.com/privacy-tech-lab/gpc-optmeowt#readme",
  "dependencies": {
    "animate.css": "^4.1.1",
    "darkmode-js": "^1.5.7",
    "file-saver": "^2.0.5",
    "idb": "^7.1.1",
    "mocha": "^10.8.2",
    "mustache": "^4.2.0",
    "path": "^0.12.7",
    "psl": "^1.8.0",
    "puppeteer": "^22.15.0",
    "rimraf": "^3.0.2",
    "tippy.js": "^6.3.7",
    "uikit": "3.6.9"
  },
  "devDependencies": {
    "@babel/core": "^7.21.3",
    "@babel/preset-env": "^7.20.2",
    "babel-loader": "^9.1.2",
    "clean-webpack-plugin": "^4.0.0",
    "concurrently": "^6.2.1",
    "copy-webpack-plugin": "^14.0.0",
    "css-loader": "^5.2.7",
    "file-loader": "^6.2.0",
    "html-webpack-plugin": "^5.3.2",
    "prettier": "^2.3.2",
    "string-replace-loader": "^3.0.3",
    "style-loader": "^2.0.0",
    "wait-on": "^7.2.0",
    "webpack": "^5.105.0",
    "webpack-cli": "^4.8.0",
    "webpack-dev-server": "^5.2.4",
    "workbox-webpack-plugin": "^7.3.0"
  },
  "overrides": {
    "serialize-javascript": "^7.0.4"
  },
  "resolutions": {
    "ws": "^8.17.1"
  }
}

================================================
FILE: src/background/control.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
control.js
================================================================================
control.js manages persistent data, message liseteners, in particular
to manage the state & functionality mode of the extension
*/

import {
  init as initProtection_ff,
  halt as haltProtection_ff,
} from "./protection/protection-ff.js";
import {
  init as initProtection_cr,
  halt as haltProtection_cr,
} from "./protection/protection.js";
import { defaultSettings } from "../data/defaultSettings.js";
import { stores, storage } from "./storage.js";
import { reloadDynamicRules } from "../common/editRules.js";

import {
  debug_domainlist_and_dynamicrules,
  updateRemovalScript,
} from "../common/editDomainlist.js";

async function enable() {
  var initProtection = initProtection_cr;
  initProtection();
}

function disable() {
  var haltProtection = haltProtection_cr;
  haltProtection();
}

/******************************************************************************/
// Initializers

// This is the very first thing the extension runs
(async () => {
    chrome.scripting.registerContentScripts([
      {
        id: "1",
        matches: ["<all_urls>"],
        excludeMatches:["https://example.com/"],
        js: ["content-scripts/registration/gpc-dom.js"],
        runAt: "document_start",
      }
    ]);

  // Check if the browser is Firefox
if ("$BROWSER" == "firefox") {
  chrome.runtime.onInstalled.addListener(function (details) {
    if (details.reason === 'install') {
      chrome.runtime.openOptionsPage((result) => {});
    }
  });
  }
  // Initializes the default settings
  let settingsDB = await storage.getStore(stores.settings);
  for (let setting in defaultSettings) {
    if (typeof settingsDB[setting] === "undefined") {
      await storage.set(stores.settings, defaultSettings[setting], setting);
    }
  }
  const localSettings = await chrome.storage.local.get(
    "WELLKNOWN_CHECK_ENABLED"
  );
  if (typeof localSettings.WELLKNOWN_CHECK_ENABLED === "undefined") {
    await chrome.storage.local.set({
      WELLKNOWN_CHECK_ENABLED: defaultSettings["WELLKNOWN_CHECK_ENABLED"],
    });
  }

  let isEnabled = await storage.get(stores.settings, "IS_ENABLED");

  if (isEnabled) {
    // Turns on the extension
    enable();
    updateRemovalScript();
    reloadDynamicRules();
  }

})();

/******************************************************************************/
// Mode listeners

// (1) Handle extension activeness is changed by calling all halt
// 	 - Make sure that I switch extensionmode and separate it from mode.domainlist
// (2) Handle extension functionality with listeners and message passing

/**
 * Listeners for information from --POPUP-- or --OPTIONS-- page
 * This is the main "hub" for message passing between the extension components
 * https://developer.chrome.com/docs/extensions/mv3/messaging/
 */
chrome.runtime.onMessage.addListener(async function (
  message
) {
  if (message.msg === "TURN_ON_OFF") {
    let isEnabled = message.data.isEnabled; // can be undefined

    if (isEnabled) {
      await storage.set(stores.settings, true, "IS_ENABLED");
      enable();
    } else {
      await storage.set(stores.settings, false, "IS_ENABLED");
      disable();
    }
  }

  if (message.msg === "CHANGE_IS_DOMAINLISTED") {
    let isDomainlisted = message.data.isDomainlisted; // can be undefined // not used
  }
});


================================================
FILE: src/background/protection/background.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
background.js
================================================================================
background.js is the main background script handling OptMeowt's
main opt-out functionality
*/

import { enableListeners, disableListeners } from "./listeners-$BROWSER.js";
import { stores, storage } from "../storage.js";
import { defaultSettings } from "../../data/defaultSettings.js";

// We could alt. use this in place of "building" for chrome/ff, just save it to settings in storage
var userAgent =
  window.navigator.userAgent.indexOf("Firefox") > -1 ? "moz" : "chrome";

/******************************************************************************/

/**
 * Enables extension functionality and sets site listeners
 * Information regarding the functionality and timing of webRequest and webNavigation
 * can be found on Mozilla's & Chrome's API docuentation sites (also linked above)
 *
 * The actual listeners are located in `listeners-(chosen browser).js`
 * The functions called on event occurance are located in `events.js`
 *
 * HIERARCHY:   manifest.json --> protection --> background.js --> listeners-$BROWSER.js --> events.js
 */

/******************************************************************************/

/**
 * Initializes the extension
 * Place all initialization necessary, as high level as can be, here.
 */
async function init() {
  enableListeners();
}

function halt() {
  disableListeners();
}

/******************************************************************************/

export const background = {
  init,
  halt,
};


================================================
FILE: src/background/protection/listeners-chrome.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
listeners-chrome.js
================================================================================
listeners-chrome.js holds the on-page-visit listeners for chrome that activate 
our main functionality
*/

// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest
// https://developer.chrome.com/docs/extensions/reference/webRequest/
// This is the extraInfoSpec array of strings
const CHROME_REQUEST_SPEC = ["requestHeaders", "extraHeaders"];
const CHROME_RESPONSE_SPEC = ["responseHeaders", "extraHeaders"];
// This is the filter object
const FILTER = { urls: ["<all_urls>"] };

/**
 * Enables extension functionality and sets site listeners
 * Information regarding the functionality and timing of webRequest and webNavigation
 * can be found on Mozilla's & Chrome's API docuentation sites (also linked above)
 *
 * The functions called on event occurance are located in `events.js`
 */
function enableListeners(callbacks) {
  const {
    onBeforeSendHeaders,
    onHeadersReceived,
    onBeforeNavigate,
    onCommitted,
    onCompleted,
  } = callbacks;

  // (4) global Chrome listeners
  chrome.webRequest.onBeforeSendHeaders.addListener(
    onBeforeSendHeaders,
    FILTER,
    CHROME_REQUEST_SPEC
  );
  chrome.webRequest.onHeadersReceived.addListener(
    onHeadersReceived,
    FILTER,
    CHROME_RESPONSE_SPEC
  );
  chrome.webNavigation.onBeforeNavigate.addListener(onBeforeNavigate, FILTER);
  chrome.webNavigation.onCommitted.addListener(onCommitted, FILTER);
  chrome.webNavigation.onCompleted.addListener(onCompleted, FILTER);
}

/**
 * Disables background listeners
 */
function disableListeners(callbacks) {
  const {
    onBeforeSendHeaders,
    onHeadersReceived,
    onBeforeNavigate,
    onCommitted,
    onCompleted,
  } = callbacks;

  chrome.webRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeaders);
  chrome.webRequest.onHeadersReceived.removeListener(onHeadersReceived);
  chrome.webNavigation.onBeforeNavigate.removeListener(onBeforeNavigate);
  chrome.webNavigation.onCommitted.removeListener(onCommitted);
  chrome.webNavigation.onCompleted.removeListener(onCompleted);
}

export { enableListeners, disableListeners };


================================================
FILE: src/background/protection/listeners-firefox.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
listeners-firefox.js
================================================================================
listeners-firefox.js holds the on-page-visit listeners for firefox that activate 
our main functionality
*/

// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest
// https://developer.chrome.com/docs/extensions/reference/webRequest/
// This is the extraInfoSpec array of strings
const MOZ_REQUEST_SPEC = ["requestHeaders", "blocking"];
const MOZ_RESPONSE_SPEC = ["responseHeaders", "blocking"];

// This is the filter object
const FILTER = { urls: ["<all_urls>"] };

/**
 * Enables extension functionality and sets site listeners
 * Information regarding the functionality and timing of webRequest and webNavigation
 * can be found on Mozilla's & Chrome's API docuentation sites (also linked above)
 *
 * The functions called on event occurance are located in `events.js`
 */
function enableListeners(callbacks) {
  const {
    onBeforeSendHeaders,
    onHeadersReceived,
    onBeforeNavigate,
    onCommitted,
    onCompleted,
  } = callbacks;

  // (4) global Firefox listeners
  chrome.webRequest.onBeforeSendHeaders.addListener(
    onBeforeSendHeaders,
    FILTER,
    MOZ_REQUEST_SPEC
  );
  chrome.webRequest.onHeadersReceived.addListener(
    onHeadersReceived,
    FILTER,
    MOZ_RESPONSE_SPEC
  );
  chrome.webNavigation.onBeforeNavigate.addListener(onBeforeNavigate);
  chrome.webNavigation.onCommitted.addListener(onCommitted);
  chrome.webNavigation.onCompleted.addListener(onCompleted);
}

/**
 * Disables background listeners
 */
function disableListeners(callbacks) {
  const {
    onBeforeSendHeaders,
    onHeadersReceived,
    onBeforeNavigate,
    onCommitted,
    onCompleted,
  } = callbacks;

  chrome.webRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeaders);
  chrome.webRequest.onHeadersReceived.removeListener(onHeadersReceived);
  chrome.webNavigation.onBeforeNavigate.removeListener(onBeforeNavigate);
  chrome.webNavigation.onCommitted.removeListener(onCommitted);
  chrome.webNavigation.onCompleted.removeListener(onCompleted);
}

export { enableListeners, disableListeners };


================================================
FILE: src/background/protection/protection-ff.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
protection.js
================================================================================
protection.js (1) Implements our per-site functionality for the background listeners
              (2) Handles cached values & message passing to popup & options page
*/

import { stores, storage } from "../storage.js";
import { defaultSettings } from "../../data/defaultSettings.js";
import { headers } from "../../data/headers.js";
import { enableListeners, disableListeners } from "./listeners-$BROWSER.js";
import psl from "psl";
import { isWellknownCheckEnabled } from "../../common/settings.js";

/******************************************************************************/
/******************************************************************************/
/**********             # Initializers (cached values)               **********/
/******************************************************************************/
/******************************************************************************/

var domainlist = {}; // Caches & mirrors domainlist in storage
var isDomainlisted = defaultSettings["IS_DOMAINLISTED"];
var tabs = {};          // Caches all tab infomration, i.e. requests, etc. 
var wellknown = {};     // Caches wellknown info to be sent to popup
var signalPerTab = {};  // Caches if a signal is sent to render the popup icon
var activeTabID = 0;    // Caches current active tab id
var sendSignal = true;  // Caches if the signal can be sent to the curr domain
var domPrev3rdParties = {}; //stores all the 3rd parties by domain (resets when you quit chrome)
var globalParsedDomain;

async function reloadVars() {
  let storedDomainlisted = await storage.get(
    stores.settings,
    "IS_DOMAINLISTED"
  );
  if (storedDomainlisted) {
    isDomainlisted = storedDomainlisted;
  }
}

reloadVars();


/******************************************************************************/
/******************************************************************************/
/**********       # Lisetener callbacks - Main functionality         **********/
/******************************************************************************/
/******************************************************************************/

/*
 * The four following functions are all related to the four main listeners in
 * `background.js`. These four functions implement all the other helper
 * functions below
 */

const listenerCallbacks = {
  /**
   * Handles all signal processessing prior to sending request headers
   * @param {object} details - retrieved info passed into callback
   * @returns {array} details.requestHeaders from addHeaders
   */
  onBeforeSendHeaders: async (details) => {
    await updateDomainlist(details);

    if (true) {
      signalPerTab[details.tabId] = true;
      return addHeaders(details);
    }
  },

  /**
   * @param {object} details - retrieved info passed into callback
   */
  onHeadersReceived: (details) => {
    logData(details);
  },

  /**
   * @param {object} details - retrieved info passed into callback
   */
  onBeforeNavigate: (details) => {
    // Resets certain cached info
    if (details.frameId === 0) {
      wellknown[details.tabId] = null;
      signalPerTab[details.tabId] = false;
      tabs[activeTabID].REQUEST_DOMAINS = {};
    }
  },

  /**
   * Adds DOM property
   * @param {object} details - retrieved info passed into callback
   */
  onCommitted: async (details) => {
    if (true) {
      addDomSignal(details);
      updatePopupIcon(details);
    }
  },
}; // closes listenerCallbacks object

/******************************************************************************/
/******************************************************************************/
/**********      # Listener helper fxns - Main functionality         **********/
/******************************************************************************/
/******************************************************************************/

/**
 * Attaches headers from `headers.js` to details.requestHeaders
 * @param {object} details - retrieved info passed into callback
 * @returns {array} details.requestHeaders
 */
function addHeaders(details) {
  console.log("addHeaders called");
  for (let signal in headers) {
    let s = headers[signal];
    details.requestHeaders.push({ name: s.name, value: s.value });
  }
  return { requestHeaders: details.requestHeaders };
}

/**
 * Runs `dom.js` to attach DOM signal
 * @param {object} details - retrieved info passed into callback
 */
function addDomSignal(details) {
  console.log("addDomSignal called");
  chrome.scripting.executeScript(details.tabId, {
    file: "../../content-scripts/injection/gpc-dom.js",
    frameId: details.frameId, // Supposed to solve multiple injections
    // as opposed to allFrames: true
    runAt: "document_start",
  });
}

function getCurrentParsedDomain() {
  return new Promise((resolve, reject) => {
    try {
      chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
        let tab = tabs[0];
        let url = new URL(tab.url);
        let parsed = psl.parse(url.hostname);
        let domain = parsed.domain;
        globalParsedDomain = domain;  // for global scope variable
        resolve(domain);
      });
    } catch(e) {
      reject();
    }
  })
}

/**
 * Checks whether a particular domain should receive a DNS signal
 * (1) Parse url to get domain for domainlist
 * (2) Update domains by adding current domain to domainlist in storage.
 * (3) Updates the 3rd party list for the currentDomain
 * (4) Check to see if we should send signal.
 * 
 * Currently, it only adds to domainlist store as NULL if it doesnt exist
 * @param {Object} details - callback object according to Chrome API
 */
 async function updateDomainlist(details) {
  let url = new URL(details.url);
  let parsedUrl = psl.parse(url.hostname);
  let parsedDomain = parsedUrl.domain;
  if (parsedDomain == null || parsedDomain == undefined) {
    return;
  }

  let parsedDomainVal = domainlist[parsedDomain];
  if (parsedDomainVal === undefined) {
    storage.set(stores.domainlist, null, parsedDomain); // Sets to storage async
    domainlist[parsedDomain] = null; // Sets to cache
    parsedDomainVal = null;
  }

  //get the current parsed domain--this is used to store 3rd parties (using globalParsedDomain variable)
 
  let currentDomain = await getCurrentParsedDomain(); 
  //initialize the objects
  if (!(activeTabID in domPrev3rdParties)){
    domPrev3rdParties[activeTabID] = {};
  }
  if (!(currentDomain in domPrev3rdParties[activeTabID]) ){
    domPrev3rdParties[activeTabID][currentDomain] = {};
  }
  //as they come in, add the parsedDomain to the object with null value (just a placeholder)
  domPrev3rdParties[activeTabID][currentDomain][parsedDomain] = null;
  

  (isDomainlisted) 
    ? ((parsedDomainVal === null) ? sendSignal = true : sendSignal = false)
    : sendSignal = true;
}

function updatePopupIcon(details) {
  if (wellknown[details.tabId] === undefined) {
    wellknown[details.tabId] = null;
  }
  if (wellknown[details.tabId] === null) {
    chrome.browserAction.setIcon({
      tabId: details.tabId,
      path: "assets/face-icons/optmeow-face-circle-green-ring-128.png",
    });
  }
}

function logData(details) {
  let url = new URL(details.url);
  let parsed = psl.parse(url.hostname);

  if (tabs[details.tabId] === undefined) {
    tabs[details.tabId] = { DOMAIN: null, REQUEST_DOMAINS: {}, TIMESTAMP: 0 };
    tabs[details.tabId].REQUEST_DOMAINS[parsed.domain] = {
      URLS: {},
      RESPONSE: details.responseHeaders,
      TIMESTAMP: details.timeStamp,
    };
    tabs[details.tabId].REQUEST_DOMAINS[parsed.domain].URLS = {
      URL: details.url,
      RESPONSE: details.responseHeaders,
    };
  } else {
    if (tabs[details.tabId].REQUEST_DOMAINS[parsed.domain] === undefined) {
      tabs[details.tabId].REQUEST_DOMAINS[parsed.domain] = {
        URLS: {},
        RESPONSE: details.responseHeaders,
        TIMESTAMP: details.timeStamp,
      };
      tabs[details.tabId].REQUEST_DOMAINS[parsed.domain].URLS[details.url] = {
        RESPONSE: details.responseHeaders,
      };
    } else {
      tabs[details.tabId].REQUEST_DOMAINS[parsed.domain].URLS[details.url] = {
        RESPONSE: details.responseHeaders,
      };
    }
  }
}

async function pullToDomainlistCache() {
  let domain;
  let domainlistKeys = await storage.getAllKeys(stores.domainlist);
  let domainlistValues = await storage.getAll(stores.domainlist);
  for (let key in domainlistKeys) {
    domain = domainlistKeys[key];
    domainlist[domain] = domainlistValues[key];
  }
}

async function syncDomainlists() {
  // (1) Reconstruct a domainlist indexedDB object from storage
  // (2) Iterate through local domainlist
  // --- If item in cache NOT in domainlistKeys/domainlistDB, add to storage
  //     via storage.set()
  // (3) Iterate through all domain keys in indexedDB domainlist
  // --- If key NOT in cached domainlist, add to cached domainlist

  let domainlistKeys = await storage.getAllKeys(stores.domainlist);
  let domainlistValues = await storage.getAll(stores.domainlist);
  let domainlistDB = {};
  let domain;
  for (let key in domainlistKeys) {
    domain = domainlistKeys[key];
    domainlistDB[domain] = domainlistValues[key];
  }

  for (let domainKey in domainlist) {
    if (!domainlistDB[domainKey]) {
      await storage.set(stores.domainlist, domainlist[domainKey], domainKey);
    }
  }

  for (let domainKey in domainlistDB) {
    if (!domainlist[domainKey]) {
      domainlist[domainKey] = domainlistDB[domainKey];
    }
  }
}

/**
 * whether the curr site should get privacy signals
 * (We need to try and make a synchronous version, esp. for DOM issue & related
 * message passing with the contentscript which injects the DOM signal)
 * @returns {bool} sendSignal
 */
async function sendPrivacySignal(domain) {
  let sendSignal;
  const extensionEnabled = await storage.get(stores.settings, "IS_ENABLED");
  const extensionDomainlisted = await storage.get(
    stores.settings,
    "IS_DOMAINLISTED"
  );
  const domainDomainlisted = await storage.get(stores.domainlist, domain);

  if (extensionEnabled) {
    if (extensionDomainlisted) {
      // Recall we must flip the value of the domainlisted domain
      // due to how to how defined domainlisted values, corresponding to MV3
      // declarativeNetRequest rule exceptions
      // (i.e., null => no rule exists, valued => exception rule exists)
      sendSignal = !domainDomainlisted ? true : false;
    } else {
      sendSignal = true;
    }
  } else {
    sendSignal = false;
  }
  return sendSignal;
}

/******************************************************************************/
/******************************************************************************/
/**********          # Message Passing - Popup helper fxns           **********/
/******************************************************************************/
/******************************************************************************/

function handleSendMessageError() {
  const error = chrome.runtime.lastError;
  if (error) {
    console.warn(error.message);
  }
}

// Info back to popup
function dataToPopup() {

  let requestsData = {};  
  
  if (tabs[activeTabID] !== undefined) {

    requestsData = domPrev3rdParties[activeTabID][globalParsedDomain];
    console.log("requests by tabID:", domPrev3rdParties);
  }

  chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
    let tabID = tabs[0]["id"];
    let wellknownData = wellknown[tabID];

    let popupData = {
      requests: requestsData,
      wellknown: wellknownData,
    };

    chrome.runtime.sendMessage(
      {
        msg: "POPUP_PROTECTION_DATA",
        data: popupData,
      },
      handleSendMessageError
    );
  });
}

/******************************************************************************/
/******************************************************************************/
/**********                   # Message passing                      **********/
/******************************************************************************/
/******************************************************************************/

/**
 * Currently only handles syncing domainlists between storage and memory
 * This runs when the popup disconnects from the background page
 * @param {Port} port
 */
function onConnectHandler(port) {
  if (port.name === "POPUP") {
    port.onDisconnect.addListener(function () {
      syncDomainlists();
    });
  }
}

/**
 * This is currently only to handle adding the GPC DOM signal.
 * I'm not sure how to fit it into an async call, it doesn't want to connect.
 * It would be nice to merge the two onMessage handlers.
 * TODO: This method still seems to have a timing issue. Doesn't always show DOM signal as thumbs up on reference site.
 * @returns {Bool} true (lets us send asynchronous responses to senders)
 */
function onMessageHandlerSynchronous(message, sender, sendResponse) {
  if (message.msg === "APPEND_GPC_PROP") {
    let url = new URL(sender.origin);
    let parsed = psl.parse(url.hostname);
    let domain = parsed.domain;

    const r = sendPrivacySignal(domain);
    r.then((r) => {
      const response = {
        msg: "APPEND_GPC_PROP_RESPONSE",
        sendGPC: r,
      };
      sendResponse(response);
    });
  }
  return true;
}

/**
 * Listeners for information from --POPUP-- or --OPTIONS-- page
 * This is the main "hub" for message passing between the extension components
 * https://developer.chrome.com/docs/extensions/mv3/messaging/
 */
async function onMessageHandlerAsync(message, sender, sendResponse) {
  if (message.msg === "GET_WELLKNOWN_CHECK_ENABLED") {
    const enabled = await isWellknownCheckEnabled();
    await chrome.storage.local.set({ WELLKNOWN_CHECK_ENABLED: enabled });
    sendResponse({ enabled });
    return true;
  }
  if (message.msg === "TOGGLE_WELLKNOWN_CHECK") {
    const enabled = message.data?.enabled !== false;
    await storage.set(stores.settings, enabled, "WELLKNOWN_CHECK_ENABLED");
    await chrome.storage.local.set({ WELLKNOWN_CHECK_ENABLED: enabled });
    if (!enabled) {
      await storage.clear(stores.wellknownInformation);
      wellknown = {};
    }
  }
  if (message.msg === "CHANGE_IS_DOMAINLISTED") {
    isDomainlisted = message.data.isDomainlisted;
    storage.set(stores.settings, isDomainlisted, "IS_DOMAINLISTED");
  }
  if (message.msg === "SET_TO_DOMAINLIST") {
    let { domain, key } = message.data;
    domainlist[domain] = key; // Sets to cache
    storage.set(stores.domainlist, key, domain); // Sets to long term storage
  }
  if (message.msg === "REMOVE_FROM_DOMAINLIST") {
    let domain = message.data;
    delete domainlist[domain];
  }
  if (message.msg === "POPUP_PROTECTION") {
    dataToPopup();
  }
  if (message.msg === "CONTENT_SCRIPT_WELLKNOWN") {
    const wellknownCheckEnabled = await isWellknownCheckEnabled();
    if (!wellknownCheckEnabled) {
      return true;
    }
    let tabID = sender.tab.id;
    wellknown[tabID] = message.data;
    if (wellknown[tabID]["gpc"] === true) {
      setTimeout(() => {}, 10000);
      if (signalPerTab[tabID] === true) {
        chrome.browserAction.setIcon({
          tabId: tabID,
          path: "assets/face-icons/optmeow-face-circle-green-128.png",
        });
      }
    }
  }

  if (message.msg === "CONTENT_SCRIPT_TAB") {
    let url = new URL(sender.origin);
    let parsed = psl.parse(url.hostname);
    let domain = parsed.domain;
    let tabID = sender.tab.id;
    if (tabs[tabID] === undefined) {
      tabs[tabID] = {
        DOMAIN: domain,
        REQUEST_DOMAINS: {},
        TIMESTAMP: message.data,
      };
    } else if (tabs[tabID].DOMAIN !== domain) {
      tabs[tabID].DOMAIN = domain;
      let urls = tabs[tabID]["REQUEST_DOMAINS"];
      for (let key in urls) {
        if (urls[key]["TIMESTAMP"] >= message.data) {
          tabs[tabID]["REQUEST_DOMAINS"][key] = urls[key];
        } else {
          delete tabs[tabID]["REQUEST_DOMAINS"][key];
        }
      }
      tabs[tabID]["TIMESTAMP"] = message.data;
    }
  }
  if (message.msg === "FORCE_RELOAD") {
    pullToDomainlistCache();
  }
  return true; // Async callbacks require this
}

function initMessagePassing() {
  chrome.runtime.onConnect.addListener(onConnectHandler);
  chrome.runtime.onMessage.addListener(onMessageHandlerAsync);
  chrome.runtime.onMessage.addListener(onMessageHandlerSynchronous);
}

function closeMessagePassing() {
  chrome.runtime.onConnect.removeListener(onConnectHandler);
  chrome.runtime.onMessage.removeListener(onMessageHandlerAsync);
  chrome.runtime.onMessage.removeListener(onMessageHandlerSynchronous);
}

/******************************************************************************/
/******************************************************************************/
/**********       # Other initializers - run once per enable         **********/
/******************************************************************************/
/******************************************************************************/

/**
 * Listener for tab switch that updates the cached current tab variable
 */
function onActivatedProtectionMode(info) {
  activeTabID = info.tabId;
}

// Handles misc. setup & setup listeners
function initSetup() {
  pullToDomainlistCache();

  // Runs on startup to initialize the cached current tab variable
  chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
    if (tabs.id) {
      activeTabID = tabs.id;
    }
  });

  chrome.tabs.onActivated.addListener(onActivatedProtectionMode);
}

function closeSetup() {
  chrome.tabs.onActivated.removeListener(onActivatedProtectionMode);
}

/**
 * Inteded to facilitate transitioning between analysis & protection modes
 */
function wipeLocalVars() {
  domainlist = {}; // Caches & mirrors domainlist in storage
  tabs = {}; // Caches all tab infomration, i.e. requests, etc.
  wellknown = {}; // Caches wellknown info to be sent to popup
  signalPerTab = {}; // Caches if a signal is sent to render the popup icon
  activeTabID = 0; // Caches current active tab id
  sendSignal = false; // Caches if the signal can be sent to the curr domain
}

/******************************************************************************/
/******************************************************************************/
/**********           # Exportable init / halt functions             **********/
/******************************************************************************/
/******************************************************************************/

export function init() {
  reloadVars();
  enableListeners(listenerCallbacks);
  initMessagePassing();
  initSetup();
}


export function halt() {
  disableListeners(listenerCallbacks);
  closeMessagePassing();
  closeSetup();
  wipeLocalVars();
}


================================================
FILE: src/background/protection/protection.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
protection.js
================================================================================
protection.js (1) Implements our per-site functionality for the background listeners
          (2) Handles cached values & message passing to popup & options page
*/

import { stores, storage } from "./../storage.js";
import { defaultSettings } from "../../data/defaultSettings.js";
import { enableListeners, disableListeners } from "./listeners-$BROWSER.js";
import psl from "psl";

import {
  addDynamicRule,
  deleteDynamicRule,
  reloadDynamicRules,
} from "../../common/editRules.js";
import { isWellknownCheckEnabled, isComplianceCheckEnabled, getUserState } from "../../common/settings.js";
import { fetchComplianceData, isCacheValid } from "../../data/complianceData.js";

/******************************************************************************/
/******************************************************************************/
/**********             # Initializers (cached values)               **********/
/******************************************************************************/
/******************************************************************************/

var domainlist = {}; // Caches & mirrors domainlist in storage
var isDomainlisted = defaultSettings["IS_DOMAINLISTED"];
var tabs = {};          // Caches all tab infomration, i.e. requests, etc. 
var wellknown = {};     // Caches wellknown info to be sent to popup
var signalPerTab = {};  // Caches if a signal is sent to render the popup icon
var activeTabID = 0;    // Caches current active tab id
var sendSignal = true;  // Caches if the signal can be sent to the curr domain
var domPrev3rdParties = {}; //stores all the 3rd parties by domain (resets when you quit chrome)
var globalParsedDomain;
var setup = false;
// complianceData cache is now handled by the IndexedDB store "stores.complianceData"
const DEFAULT_NO_DATA_STATUS = {
  status: 'no_data',
  details: 'We do not have data for this site.',
  lastChecked: null
};

async function reloadVars() {
  let storedDomainlisted = await storage.get(
    stores.settings,
    "IS_DOMAINLISTED"
  );
  if (storedDomainlisted) {
    isDomainlisted = storedDomainlisted;
  }
}

reloadVars();

/******************************************************************************/
/******************************************************************************/
/**********       # Lisetener callbacks - Main functionality         **********/
/******************************************************************************/
/******************************************************************************/

/*
 * The four following functions are all related to the four main listeners in
 * `background.js`. These four functions implement all the other helper
 * functions below
 */

const listenerCallbacks = {
  /**
   * Handles all signal processessing prior to sending request headers
   * @param {object} details - retrieved info passed into callback
   * @returns {array}
   */
  onBeforeSendHeaders: async (details) => {
    await updateDomainlist(details);
  },

  /**
   * @param {object} details - retrieved info passed into callback
   */
  onHeadersReceived: async (details) => {
    //if (!setup){
    //initSetup();
    //}
    await logData(details);
    await sendData();



  },

  /**
   * @param {object} details - retrieved info passed into callback
   */
  onBeforeNavigate: (details) => {
    // Resets certain cached info
  },

  /**
   * Adds DOM property
   * @param {object} details - retrieved info passed into callback
   */
  onCommitted: async (details) => {
    await updateDomainlist(details);
  },

  onCompleted: async (details) => {
    await sendData();
    await handleComplianceCheck(details);
  }

}; // closes listenerCallbacks object

/******************************************************************************/
/******************************************************************************/
/**********      # Listener helper fxns - Main functionality         **********/
/******************************************************************************/
/******************************************************************************/


/**
 * Fetches compliance data if not cached or cache is stale
 * @returns {Promise<Object|null>} - Metadata map containing stateCode or null if disabled/error
 */
async function getComplianceData() {
  const stateCode = await getUserState();
  if (!stateCode || stateCode === 'none') {
    return null;
  }

  // Check if we have valid cached data in IndexedDB
  const metadata = await storage.get(stores.complianceData, '_metadata');
  
  // Invalidate cache if state changed
  if (metadata && metadata.stateCode && metadata.stateCode !== stateCode) {
    await storage.clear(stores.complianceData);
  } else if (metadata && isCacheValid(metadata.fetchedAt)) {
    return metadata; // Cache is valid, return metadata to signify readiness
  }

  // Fetch fresh data for the selected state
  try {
    const result = await fetchComplianceData(stateCode);

    // fetchComplianceData returns { error: 'fetch_error' } on network/server failure
    if (result.error === 'fetch_error') {
      console.warn(`Compliance data unavailable for ${stateCode} (server/network error)`);
      return { _fetchError: true };
    }

    // Save individual domains to indexedDB instead of holding a huge object in memory
    const dataKeys = Object.keys(result.data);
    for (const key of dataKeys) {
      await storage.set(stores.complianceData, result.data[key], key);
    }

    // Store metadata in storage (including viewUrl for the popup's dataset link)
    const newMetadata = {
      fetchedAt: result.fetchedAt,
      count: result.count,
      stateCode,
      viewUrl: result.viewUrl || null,
    };
    await storage.set(stores.complianceData, newMetadata, '_metadata');

    // Notify the popup that fresh compliance data is ready to be painted!
    chrome.runtime.sendMessage({
      msg: "COMPLIANCE_DATA_READY"
    }).catch(e => {
      // Ignored: Popup might be closed
    });

    console.log(`Fetched ${stateCode} compliance data for ${result.count} domains`);
    return newMetadata;
  } catch (error) {
    console.error('Failed to fetch compliance data:', error);
    return null;
  }
}

/**
 * Looks up and stores compliance status for current domain after page load
 * @param {Object} details - callback object from onCompleted listener
 */
async function handleComplianceCheck(details) {
  // Only check main frame navigations
  if (details.frameId !== 0) return;

  const stateCode = await getUserState();
  if (!stateCode || stateCode === 'none') {
    return;
  }

  try {
    const url = new URL(details.url);
    const parsed = psl.parse(url.hostname);
    const domain = parsed.domain;

    if (!domain) return;

    console.log('Running compliance check for:', domain);

    const metadata = await storage.get(stores.complianceData, '_metadata');
    const cacheIsCold = !metadata || !isCacheValid(metadata.fetchedAt);
    if (cacheIsCold) {
      await storage.set(stores.settings, true, 'COMPLIANCE_LOADING');
      // Tell popup we are loading
      chrome.runtime.sendMessage({ msg: "COMPLIANCE_DATA_LOADING" }).catch(() => {});
    }

    // Wrap fetch + process + store in one try/finally so COMPLIANCE_LOADING is
    // only cleared AFTER the domain status is in storage. Clearing it earlier
    // caused the popup poll to read before the write completed ("Not in Dataset").
    try {
      const complianceDataMeta = await getComplianceData();

      // Server/network was unreachable — store fetch_error so popup can show it
      if (complianceDataMeta && complianceDataMeta._fetchError) {
        await storage.set(stores.complianceData, { status: 'fetch_error' }, domain);
        return;
      }

      if (!complianceDataMeta) {
        console.log('No compliance data available');
        return;
      }

      const status = await storage.get(stores.complianceData, domain) || DEFAULT_NO_DATA_STATUS;

      console.log('Compliance status for', domain, ':', status.status);

      // Write status to storage FIRST, then clear loading flag
      await storage.set(stores.complianceData, status, domain);
    } finally {
      // Only clear after the write above completes (or on any error path)
      if (cacheIsCold) {
        await storage.set(stores.settings, false, 'COMPLIANCE_LOADING');
        // Notify popup that load is successful and store is populated
        chrome.runtime.sendMessage({ msg: "COMPLIANCE_DATA_READY" }).catch(() => {});
      }
    }
  } catch (error) {
    console.debug('Error in compliance check:', error);
    // Ensure loading flag is cleared on unexpected errors
    await storage.set(stores.settings, false, 'COMPLIANCE_LOADING');
  }
}

async function sendData() {
  let activeTab = await chrome.tabs.query({ active: true, currentWindow: true });
  let activeTabID = activeTab.length > 0 ? activeTab[0].id : null;

  if (activeTabID === null) {
    return;
  }

  let currentDomain = await getCurrentParsedDomain();
  if (!currentDomain) {
    return;
  }

  const partiesForTab = domPrev3rdParties?.[activeTabID];
  const info = partiesForTab ? partiesForTab[currentDomain] : null;

  if (!info) {
    await storage.delete(stores.thirdParties, currentDomain);
    return;
  }

  const data = Object.keys(info).filter(Boolean);
  await storage.set(stores.thirdParties, data, currentDomain);

}


function getCurrentParsedDomain() {
  return new Promise((resolve) => {
    chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
      try {
        const tab = tabs && tabs[0];
        if (!tab || !tab.url) {
          return resolve(null);
        }
        const url = new URL(tab.url);
        const parsed = psl.parse(url.hostname);
        const domain = parsed && parsed.domain ? parsed.domain : null;
        globalParsedDomain = domain;  // for global scope variable
        resolve(domain);
      } catch (e) {
        resolve(null);
      }
    });
  });
}


/**
 * Checks whether a particular domain should receive a DNS signal
 * (1) Parse url to get domain for domainlist
 * (2) Update domains by adding current domain to domainlist in storage.
 * (3) Updates the 3rd party list for the currentDomain
 * (4) Check to see if we should send signal.
 * 
 * Currently, it only adds to domainlist store as NULL if it doesnt exist
 * @param {Object} details - callback object according to Chrome API
 */
async function updateDomainlist(details) {
  if (!details || !details.url) {
    return;
  }

  let parsedDomain;
  try {
    let url = new URL(details.url);
    let parsedUrl = psl.parse(url.hostname);
    parsedDomain = parsedUrl.domain;
  } catch (e) {
    return;
  }

  if (!parsedDomain) {
    return;
  }

  let currDomainValue = await storage.get(stores.domainlist, parsedDomain);
  let id = details.tabId;

  if (currDomainValue === undefined) {
    await storage.set(stores.domainlist, null, parsedDomain); // Sets to storage async
  }

  let currentDomain = await getCurrentParsedDomain();
  if (!currentDomain) {
    return;
  }

  //get the current parsed domain--this is used to store 3rd parties (using globalParsedDomain variable)
  if (!(id in domPrev3rdParties)) {
    domPrev3rdParties[id] = {};
  }
  if (!(currentDomain in domPrev3rdParties[id])) {
    domPrev3rdParties[id][currentDomain] = {};
  }
  //as they come in, add the parsedDomain to the object with null value (just a placeholder)
  domPrev3rdParties[id][currentDomain][parsedDomain] = null;


}

function updatePopupIcon(tabId) {
  chrome.action.setIcon({
    tabId: tabId,
    path: "assets/face-icons/optmeow-face-circle-green-ring-128.png",
  });
}

async function logData(details) {
  let url = new URL(details.url);
  let parsed = psl.parse(url.hostname);

  if (tabs[details.tabId] === undefined) {
    tabs[details.tabId] = { DOMAIN: null, REQUEST_DOMAINS: {}, TIMESTAMP: 0 };
    tabs[details.tabId].REQUEST_DOMAINS[parsed.domain] = {
      URLS: {},
      RESPONSE: details.responseHeaders,
      TIMESTAMP: details.timeStamp,
    };
    tabs[details.tabId].REQUEST_DOMAINS[parsed.domain].URLS = {
      URL: details.url,
      RESPONSE: details.responseHeaders,
    };
  } else {
    if (tabs[details.tabId].REQUEST_DOMAINS[parsed.domain] === undefined) {
      tabs[details.tabId].REQUEST_DOMAINS[parsed.domain] = {
        URLS: {},
        RESPONSE: details.responseHeaders,
        TIMESTAMP: details.timeStamp,
      };
      tabs[details.tabId].REQUEST_DOMAINS[parsed.domain].URLS[details.url] = {
        RESPONSE: details.responseHeaders,
      };
    } else {
      tabs[details.tabId].REQUEST_DOMAINS[parsed.domain].URLS[details.url] = {
        RESPONSE: details.responseHeaders,
      };
    }
  }

}

async function pullToDomainlistCache() {
  let domain;
  let domainlistKeys = await storage.getAllKeys(stores.domainlist);
  let domainlistValues = await storage.getAll(stores.domainlist);

  for (let key in domainlistKeys) {
    domain = domainlistKeys[key];
    domainlist[domain] = domainlistValues[key];
  }
}

async function syncDomainlists() {
  // (1) Reconstruct a domainlist indexedDB object from storage
  // (2) Iterate through local domainlist
  // --- If item in cache NOT in domainlistKeys/domainlistDB, add to storage
  //     via storage.set()
  // (3) Iterate through all domain keys in indexedDB domainlist
  // --- If key NOT in cached domainlist, add to cached domainlist

  let domainlistKeys = await storage.getAllKeys(stores.domainlist);
  let domainlistValues = await storage.getAll(stores.domainlist);
  let domainlistDB = {};
  let domain;
  for (let key in domainlistKeys) {
    domain = domainlistKeys[key];
    domainlistDB[domain] = domainlistValues[key];
  }

  for (let domainKey in domainlist) {
    if (!domainlistDB[domainKey]) {
      await storage.set(stores.domainlist, domainlist[domainKey], domainKey);
    }
  }

  for (let domainKey in domainlistDB) {
    if (!domainlist[domainKey]) {
      domainlist[domainKey] = domainlistDB[domainKey];
    }
  }
}

/**
 * whether the curr site should get privacy signals
 * (We need to try and make a synchronous version, esp. for DOM issue & related
 * message passing with the contentscript which injects the DOM signal)
 * @returns {bool} sendSignal
 */
async function sendPrivacySignal(domain) {
  let sendSignal;
  const extensionEnabled = await storage.get(stores.settings, "IS_ENABLED");
  const extensionDomainlisted = await storage.get(
    stores.settings,
    "IS_DOMAINLISTED"
  );
  const domainDomainlisted = await storage.get(stores.domainlist, domain);

  if (extensionEnabled) {
    if (extensionDomainlisted) {
      // Recall we must flip the value of the domainlisted domain
      // due to how to how defined domainlisted values, corresponding to MV3
      // declarativeNetRequest rule exceptions
      // (i.e., null => no rule exists, valued => exception rule exists)
      sendSignal = !domainDomainlisted ? true : false;
    } else {
      sendSignal = true;
    }
  } else {
    sendSignal = false;
  }
  return sendSignal;
}

/******************************************************************************/
/******************************************************************************/
/**********          # Message Passing - Popup helper fxns           **********/
/******************************************************************************/
/******************************************************************************/

function handleSendMessageError() {
  const error = chrome.runtime.lastError;
  if (error) {
    console.warn(error.message);
  }
}
async function dataToPopupHelper() {
  //data gets sent back every time the popup is clicked
  let domain = await getCurrentParsedDomain();
  if (!domain) {
    return [];
  }

  let parties = await storage.get(stores.thirdParties, domain);
  if (!Array.isArray(parties)) {
    return [];
  }

  return parties;
}

// Info back to popup
async function dataToPopup(wellknownData) {
  let requestsData = await dataToPopupHelper(); //get requests from the helper
  chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
    let popupData = {
      requests: requestsData,
      wellknown: wellknownData,
    };

    chrome.runtime.sendMessage(
      {
        msg: "POPUP_PROTECTION_DATA",
        data: popupData,
      },
      handleSendMessageError
    );
  });
}

async function dataToPopupRequests() {
  let requestsData = await dataToPopupHelper(); //get requests from the helper
  console.log("requests data in DTPR: ", requestsData)

  chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
    chrome.runtime.sendMessage(
      {
        msg: "POPUP_PROTECTION_DATA_REQUESTS",
        data: requestsData,
      },
      handleSendMessageError
    );
  });
}

/******************************************************************************/
/******************************************************************************/
/**********                   # Message passing                      **********/
/******************************************************************************/
/******************************************************************************/

/**
 * Currently only handles syncing domainlists between storage and memory
 * This runs when the popup disconnects from the background page
 * @param {Port} port
 */
function onConnectHandler(port) {
  if (port.name === "POPUP") {
    port.onDisconnect.addListener(function () {
      syncDomainlists();
    });
  }
}

/**
 * This is currently only to handle adding the GPC DOM signal.
 * I'm not sure how to fit it into an async call, it doesn't want to connect.
 * It would be nice to merge the two onMessage handlers.
 * TODO: This method still seems to have a timing issue. Doesn't always show DOM signal as thumbs up on reference site.
 * @returns {Bool} true (lets us send asynchronous responses to senders)
 */
function onMessageHandlerSynchronous(message, sender, sendResponse) {
  if (message.msg === "APPEND_GPC_PROP") {
    let url = new URL(sender.origin);
    let parsed = psl.parse(url.hostname);
    let domain = parsed.domain;

    const r = sendPrivacySignal(domain);
    r.then((r) => {
      const response = {
        msg: "APPEND_GPC_PROP_RESPONSE",
        sendGPC: r,
      };
      sendResponse(response);
    });
  }
  //return true;
}

/**
 * Listeners for information from --POPUP-- or --OPTIONS-- page
 * This is the main "hub" for message passing between the extension components
 * https://developer.chrome.com/docs/extensions/mv3/messaging/
  */
async function onMessageHandlerAsync(message, sender, sendResponse) {
  if (message.msg === "GET_WELLKNOWN_CHECK_ENABLED") {
    const enabled = await isWellknownCheckEnabled();
    await chrome.storage.local.set({ WELLKNOWN_CHECK_ENABLED: enabled });
    sendResponse({ enabled });
    return true;
  }
  if (message.msg === "USER_STATE_CHANGE") {
    console.log("User state changed, triggering immediate compliance fetch...");

    // Trigger fetch and update current tab
    (async () => {
      try {
        // Set loading flag
        await storage.set(stores.settings, true, "COMPLIANCE_LOADING");
        chrome.runtime.sendMessage({ msg: "COMPLIANCE_DATA_LOADING" }).catch(() => {});

        const dataMeta = await getComplianceData();
        const tabs = await chrome.tabs.query({ active: true, currentWindow: true });
        if (tabs.length > 0 && tabs[0].url) {
          const url = new URL(tabs[0].url);
          const parsed = psl.parse(url.hostname);
          const domain = parsed.domain;
          if (domain) {
            // Server/network error — propagate fetch_error to the popup
            if (dataMeta && dataMeta._fetchError) {
              await storage.set(stores.complianceData, { status: 'fetch_error' }, domain);
              console.warn('Compliance config server unreachable; stored fetch_error for active domain');
            } else if (dataMeta) {
              const status = await storage.get(stores.complianceData, domain) || DEFAULT_NO_DATA_STATUS;
              await storage.set(stores.complianceData, status, domain);
              console.log(`Updated compliance storage for active domain: ${domain}`);
            }
          }
        }
      } catch (e) {
        console.error("Failed to fetch/update compliance data:", e);
      } finally {
        // Clear loading flag
        await storage.set(stores.settings, false, "COMPLIANCE_LOADING");
        chrome.runtime.sendMessage({ msg: "COMPLIANCE_DATA_READY" }).catch(() => {});
      }
    })();
    return true;
  }
  if (message.msg === "TOGGLE_WELLKNOWN_CHECK") {
    const enabled = message.data?.enabled !== false;
    await storage.set(stores.settings, enabled, "WELLKNOWN_CHECK_ENABLED");
    await chrome.storage.local.set({ WELLKNOWN_CHECK_ENABLED: enabled });
    if (!enabled) {
      await storage.clear(stores.wellknownInformation);
      wellknown = {};
    }
  }
  if (message.msg === "CHANGE_IS_DOMAINLISTED") {
    let isDomainlisted = message.data.isDomainlisted;
    storage.set(stores.settings, isDomainlisted, "IS_DOMAINLISTED");
  }
  if (message.msg === "SET_TO_DOMAINLIST") {
    let { domain, key } = message.data;
    domainlist[domain] = key; // Sets to cache
    addDynamicRule(id, domain);
    storage.set(stores.domainlist, key, domain); // Sets to long term storage
  }
  if (message.msg === "POPUP_PROTECTION_REQUESTS") {
    console.log("info queried");
    await dataToPopupRequests();
  }
  if (message.msg === "CONTENT_SCRIPT_WELLKNOWN") {
    const wellknownCheckEnabled = await isWellknownCheckEnabled();
    if (!wellknownCheckEnabled) {
      return true;
    }
    // sender.origin not working for Firefox MV3, instead added a new message argument, message.origin_url
    //let url = new URL(sender.origin);
    let url = new URL(message.origin_url);
    let parsed = psl.parse(url.hostname);
    let domain = parsed.domain;

    let tabID = sender.tab.id;
    let wellknown = [];
    let sendSignal = await storage.get(stores.domainlist, domain);

    wellknown[tabID] = message.data;
    let wellknownData = message.data;

    await storage.set(stores.wellknownInformation, wellknownData, domain);

    //await sendData();

    if (wellknown[tabID] === null && sendSignal == null) {
      updatePopupIcon(tabID);
    } else if (wellknown[tabID]["gpc"] === true && sendSignal == null) {
      chrome.action.setIcon({
        tabId: tabID,
        path: "assets/face-icons/optmeow-face-circle-green-128.png",
      });
    }
    chrome.runtime.onMessage.addListener(async function (message, _, __) {
      if (message.msg === "POPUP_PROTECTION") {
        await dataToPopup(wellknownData);
      }
    });
  }

  if (message.msg === "CONTENT_SCRIPT_TAB") {
    let url = new URL(sender.origin);
    let parsed = psl.parse(url.hostname);
    let domain = parsed.domain;
    let tabID = sender.tab.id;
    if (tabs[tabID] === undefined) {
      tabs[tabID] = {
        DOMAIN: domain,
        REQUEST_DOMAINS: {},
        TIMESTAMP: message.data,
      };
    } else if (tabs[tabID].DOMAIN !== domain) {
      tabs[tabID].DOMAIN = domain;
      let urls = tabs[tabID]["REQUEST_DOMAINS"];
      for (let key in urls) {
        if (urls[key]["TIMESTAMP"] >= message.data) {
          tabs[tabID]["REQUEST_DOMAINS"][key] = urls[key];
        } else {
          delete tabs[tabID]["REQUEST_DOMAINS"][key];
        }
      }
      tabs[tabID]["TIMESTAMP"] = message.data;
    }
  }
  return true; // Async callbacks require this
}

function initMessagePassing() {
  chrome.runtime.onConnect.addListener(onConnectHandler);
  chrome.runtime.onMessage.addListener(onMessageHandlerAsync);
  chrome.runtime.onMessage.addListener(onMessageHandlerSynchronous);
}

function closeMessagePassing() {
  chrome.runtime.onConnect.removeListener(onConnectHandler);
  chrome.runtime.onMessage.removeListener(onMessageHandlerAsync);
  chrome.runtime.onMessage.removeListener(onMessageHandlerSynchronous);
}

/******************************************************************************/
/******************************************************************************/
/**********       # Other initializers - run once per enable         **********/
/******************************************************************************/
/******************************************************************************/

/**
 * Listener for tab switch that updates the cached current tab variable
 */
function onActivatedProtectionMode(info) {
  activeTabID = info.tabId;
  console.log("onActivatedProtectionMode called");
}

// Handles misc. setup & setup listeners
function initSetup() {
  pullToDomainlistCache();

  // Runs on startup to initialize the cached current tab variable
  chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
    if (tabs.id) {
      activeTabID = tabs.id;
    }
  });

  chrome.tabs.onActivated.addListener(onActivatedProtectionMode);
  setup = true;
}

function closeSetup() {
  chrome.tabs.onActivated.removeListener(onActivatedProtectionMode);
}

/**
 * Inteded to facilitate transitioning between analysis & protection modes
 */
function wipeLocalVars() {
  domainlist = {}; // Caches & mirrors domainlist in storage
  tabs = {}; // Caches all tab infomration, i.e. requests, etc.
  wellknown = {}; // Caches wellknown info to be sent to popup
  signalPerTab = {}; // Caches if a signal is sent to render the popup icon
  activeTabID = 0; // Caches current active tab id
  sendSignal = false; // Caches if the signal can be sent to the curr domain
}

/******************************************************************************/
/******************************************************************************/
/**********           # Exportable init / halt functions             **********/
/******************************************************************************/
/******************************************************************************/

export function init() {
  reloadVars();
  enableListeners(listenerCallbacks);
  initMessagePassing();
  initSetup();
}

export function halt() {
  disableListeners(listenerCallbacks);
  closeMessagePassing();
  closeSetup();
  wipeLocalVars();
}


================================================
FILE: src/background/storage.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
storage.js
================================================================================
storage.js handles OptMeowt's reads/writes of data to some local location
*/

import { openDB } from "idb";
import { reloadDynamicRules } from "../common/editRules.js";
import pkg from 'file-saver';
const { saveAs } = pkg;

/******************************************************************************/
/**************************  Enumerated settings  *****************************/
/******************************************************************************/

// In general, these functions should be use with async / await for
// syntactic sweetness & synchronous data handling
// i.e., await storage.set(stores.settings, extensionMode.enabled, 'MODE')
const stores = Object.freeze({
  settings: "SETTINGS",
  domainlist: "DOMAINLIST",
  thirdParties: "THIRDPARTIES",
  wellknownInformation: "WELLKNOWNDATA",
  complianceData: "COMPLIANCEDATA",
});

/******************************************************************************/
/*************************  Main Storage Functions  ***************************/
/******************************************************************************/

const dbPromise = openDB("extensionDB", 2, {
  upgrade: function dbPromiseInternal(db, oldVersion) {
    // Create stores that don't exist yet
    if (!db.objectStoreNames.contains(stores.domainlist)) {
      db.createObjectStore(stores.domainlist);
    }
    if (!db.objectStoreNames.contains(stores.settings)) {
      db.createObjectStore(stores.settings);
    }
    if (!db.objectStoreNames.contains(stores.thirdParties)) {
      db.createObjectStore(stores.thirdParties);
    }
    if (!db.objectStoreNames.contains(stores.wellknownInformation)) {
      db.createObjectStore(stores.wellknownInformation);
    }
    // New in version 2
    if (oldVersion < 2 && !db.objectStoreNames.contains(stores.complianceData)) {
      db.createObjectStore(stores.complianceData);
    }
  },
});

const storage = {
  async get(store, key) {
    if (typeof key === "undefined") {
      return undefined;
    }
    return (await dbPromise).get(store, key);
  },
  async getAll(store) {
    return (await dbPromise).getAll(store);
  },
  async getAllKeys(store) {
    return (await dbPromise).getAllKeys(store);
  },
  // returns an object containing the given store
  async getStore(store) {
    const storeValues = await storage.getAll(store);
    const storeKeys = await storage.getAllKeys(store);
    let storeCopy = {};
    let key;
    for (let index in storeKeys) {
      key = storeKeys[index];
      storeCopy[key] = storeValues[index];
    }
    return storeCopy;
  },
  async set(store, value, key) {
    if (typeof key === "undefined") {
      return undefined;
    }
    return (await dbPromise).put(store, value, key);
  },
  async delete(store, key) {
    if (typeof key === "undefined") {
      return undefined;
    }
    return (await dbPromise).delete(store, key);
  },
  async clear(store) {
    return (await dbPromise).clear(store);
  },
};

/******************************************************************************/
/*********************  Importing/Exporting Domain List  **********************/
/******************************************************************************/

async function handleDownload() {
  const DOMAINLIST = await storage.getStore(stores.domainlist);
  let MANIFEST = chrome.runtime.getManifest();
  let data = {
    VERSION: MANIFEST.version,
    DOMAINLIST: DOMAINLIST,
  };

  let blob = new Blob([JSON.stringify(data, null, 4)], {
    type: "text/plain;charset=utf-8",
  });
  saveAs(blob, "OptMeowt_backup.json");
}

/**
 * Sets-up the process for importing a saved domainlist backup
 */
async function startUpload() {
  document.getElementById("upload-domainlist").value = "";
  document.getElementById("upload-domainlist").click();
}

/**
 * Imports and updates the domainlist in local storage with an imported backup
 */
async function handleUpload() {
  await storage.clear(stores.domainlist);
  const file = this.files[0];
  const fr = new FileReader();
  fr.onload = function (e) {
    const UPLOADED_DATA = JSON.parse(e.target.result);
    let version = UPLOADED_DATA.VERSION;
    let domainlist = UPLOADED_DATA.DOMAINLIST;
    version = version.split(".");

    let domainlist_keys = Object.keys(domainlist);
    let domainlist_vals = Object.values(domainlist);
    for (let i = 0; i < domainlist_keys.length; i++) {
      try {
        storage.set(stores.domainlist, domainlist_vals[i], domainlist_keys[i]);
      } catch (error) {
        alert("Error loading list");
      }
    }
    // hardcode if it is the new version // check
    if (Number(version[0]) >= 3) {
      reloadDynamicRules();
      updateRemovalScript();
    } else {
      chrome.runtime.sendMessage({
        msg: "FORCE_RELOAD",
      });
    }
  };
  fr.readAsText(file);
}

/******************************************************************************/
/******************************************************************************/
/******************************************************************************/

export { handleDownload, startUpload, handleUpload, stores, storage };


================================================
FILE: src/common/editDomainlist.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
editDomainlist.js
================================================================================
editDomainlist.js is an internal API modifying the domainlist / modifying the
domainlist simultaneously with the dynamic ruleset
*/

import { storage, stores } from "../background/storage.js";
import {
  deleteAllDynamicRules,
  deleteDynamicRule,
  addDynamicRule,
  getFreshId,
} from "./editRules.js";

/* # Debugging */
// debug_domainlist_and_dynamicrules
// print_rules_and_domainlist

/******************************************************************************/
/******************************************************************************/
/**********                  # Standard Operation                    **********/
/******************************************************************************/
/******************************************************************************/

async function updateRemovalScript() {
    let ex_matches = ["https://example.org/foo/bar.html"];
    let domain;
    let domainValue;
    const domainlistKeys = await storage.getAllKeys(stores.domainlist);
    const domainlistValues = await storage.getAll(stores.domainlist);
    for (let index in domainlistKeys) {
      domain = domainlistKeys[index];
      domainValue = domainlistValues[index];
      if (domainValue != null) {
        ex_matches.push("https://" + domain + "/*");
        ex_matches.push("https://www." + domain + "/*");
      }
    }
    chrome.scripting
      .updateContentScripts([
        {
          id: "1",
          matches: ["<all_urls>"],
          excludeMatches: ex_matches,
          js: ["content-scripts/registration/gpc-dom.js"],
          runAt: "document_start",
        },
      ])
      .then(() => {});
  }

async function createCS(domain){
    let script = await chrome.scripting.getRegisteredContentScripts({
    });

    let ex_matches = script[0].excludeMatches;

    ex_matches.push("https://" + domain + "/*");
    ex_matches.push("https://www." + domain + "/*");

    await chrome.scripting.updateContentScripts([
      {
        id: "1",
        matches: ["<all_urls>"],
        excludeMatches: ex_matches,
        js: ["content-scripts/registration/gpc-dom.js"],
        runAt: "document_start",
      },
    ])
    .then(() => {});
  }

async function deleteCS(domain){
    let script = await chrome.scripting.getRegisteredContentScripts({
    });
    let ex_matches = script[0].excludeMatches;
    function removeItemOnce(arr, value) {
      var index = arr.indexOf(value);
      if (index > -1) {
        arr.splice(index, 1);
      }
      return arr;
    }

    ex_matches = removeItemOnce(ex_matches,"https://" + domain + "/*");
    ex_matches = removeItemOnce(ex_matches,"https://www." + domain + "/*");
    await chrome.scripting.updateContentScripts([
      {
        id: "1",
        matches: ["<all_urls>"],
        excludeMatches: ex_matches,
        js: ["content-scripts/registration/gpc-dom.js"],
        runAt: "document_start",
      },
    ])
    .then(() => {});
  }

async function deleteDomainlistAndDynamicRules() {
  await storage.clear(stores.domainlist);
    deleteAllDynamicRules();
  }

async function addDomainToDomainlistAndRules(domain) {
  let id = 1;
    id = await getFreshId();
    addDynamicRule(id, domain); // add the rule for the chosen domain
    createCS(domain);
    await storage.set(stores.domainlist, id, domain); // record what rule the domain is associated to
}

async function removeDomainFromDomainlistAndRules(domain) {
    let id = await storage.get(stores.domainlist, domain);
    deleteDynamicRule(id);
    deleteCS(domain);
    await storage.set(stores.domainlist, null, domain);
  }

/******************************************************************************/
/******************************************************************************/
/**********                      # Debugging                         **********/
/******************************************************************************/
/******************************************************************************/

async function debug_domainlist_and_dynamicrules() {
  let sampleSites = [ // not called
    "a.com",
    "b.com",
    "c.com",
    "d.com",
    "e.com",
    "f.com",
    "g.com",
    "h.com",
    "i.com",
    "j.com",
  ];
  await deleteDomainlistAndDynamicRules();
  await print_rules_and_domainlist();
  addDynamicRule(2, "nytimes.com"); // add the rule for the chosen domain
  await storage.set(stores.domainlist, 2, "nytimes.com"); // record what rule the domain is associated to

  await print_rules_and_domainlist();
  await addDomainToDomainlistAndRules("a.com");
  await addDomainToDomainlistAndRules("b.com");
  await addDomainToDomainlistAndRules("c.com");
  await addDomainToDomainlistAndRules("d.com");
  await addDomainToDomainlistAndRules("e.com");
  await addDomainToDomainlistAndRules("f.com");
  await addDomainToDomainlistAndRules("g.com");
  await addDomainToDomainlistAndRules("h.com");
  await addDomainToDomainlistAndRules("i.com");
  await addDomainToDomainlistAndRules("j.com");
  await print_rules_and_domainlist();
}

async function print_rules_and_domainlist() {
  let rules = await chrome.declarativeNetRequest.getDynamicRules();
  let domainlist = await storage.getStore(stores.domainlist);
  console.log(
    "Here are the curr dynamic rules:",
    rules,
    "Here is our curr domainlist: ",
    domainlist
  );
}

/******************************************************************************/
/******************************************************************************/
/******************************************************************************/

export {
  deleteDomainlistAndDynamicRules,
  addDomainToDomainlistAndRules,
  removeDomainFromDomainlistAndRules,
  updateRemovalScript,
  debug_domainlist_and_dynamicrules,
  print_rules_and_domainlist,
  deleteCS,
  createCS
};


================================================
FILE: src/common/editRules.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

import { storage, stores } from "../background/storage.js";

/*
editRules.js
================================================================================
editRules.js is an internal API for adding/removing GPC-exclusion dynamic rules
*/

/**
 * Gets fresh rule ID for new DeclarativeNetRequest dynamic rule
 * Pulls from already set dynamic rules as opposed to domainlist values
 *
 * NOTE:  Does not 'reserve' the ID. If it isn't used on the client side,
 *        getFreshId() will spit out the same val next call.
 * @returns {Promise<(number|null)>} - number of fresh ID, null if non available
 */
export async function getFreshId() {
  const MAX_RULES =
    chrome.declarativeNetRequest.MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES;
  const rules = await chrome.declarativeNetRequest.getDynamicRules();
  let freshId = null;
  let usedRuleIds = [];

  for (let i in rules) {
    usedRuleIds.push(rules[i]["id"]);
  }
  usedRuleIds.sort((a, b) => {
    return a - b;
  }); // Necessary for next for loop

  // Make sure the ID starts at 1 (I think 0 is reserved?)
  for (let i = 1; i < MAX_RULES; i++) {
    if (i !== usedRuleIds[i - 1]) {
      freshId = i; // We have found the first nonzero, unused id
      break;
    }
  }
  return freshId;
}

/**
 * Deletes GPC-exclusion rule from rule set
 * Does NOT remove from domainlist
 * (see declarativeNetRequest)
 * @param {number} id - rule id
 */
export async function deleteDynamicRule(id) {
  let UpdateRuleOptions = { removeRuleIds: [id] };
  await chrome.declarativeNetRequest.updateDynamicRules(UpdateRuleOptions);
}

/**
 * Deletes all GPC-exclusion dynamic rules
 * (see declarativeNetRequest)
 */
export async function deleteAllDynamicRules() {
  let MAX_RULES =
    chrome.declarativeNetRequest.MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES;
  let UpdateRuleOptions = { removeRuleIds: [...Array(MAX_RULES).keys()] };
  await chrome.declarativeNetRequest.updateDynamicRules(UpdateRuleOptions);
}

/**
 * Adds domain as a rule to be excluded from receiving GPC signals
 * Note id should be fresh, o/w it will overwrite existing rule
 * (see getFreshId, declarativeNetRequest)
 * @param {number} id - rule id
 * @param {string} domain - domain to associate with id
 */
export async function addDynamicRule(id, domain) {
  let UpdateRuleOptions = {
    addRules: [
      {
        id: id,
        priority: 2,
        action: {
          type: "modifyHeaders",
          requestHeaders: [
            { "header": "Sec-GPC", "operation": "remove" },
            { "header": "DNT", "operation": "remove" },
            { "header": "Permissions-Policy", "operation": "remove"}
          ],
        },
        condition: {
          urlFilter: domain,
          resourceTypes: [
            "main_frame",
            "sub_frame",
            "stylesheet",
            "script",
            "image",
            "font",
            "object",
            "xmlhttprequest",
            "ping",
            "csp_report",
            "media",
            "websocket",
            "other",
          ],
        },
      },
    ],
    removeRuleIds: [id],
  };
  await chrome.declarativeNetRequest.updateDynamicRules(UpdateRuleOptions);
  return;
}

/**
 * Deletes all rules, queries current domainlist, and re-adds all rules
 * - Useful when replacing the domainlist via an import/export
 * - Remember rules as of v3.0.0 are 'exclusion' rules, i.e. excluded from
 *   receiving GPC or other opt-outs.
 */
export async function reloadDynamicRules() {
    deleteAllDynamicRules();
    let domainlist = await storage.getStore(stores.domainlist);

    let promises = [];
    Object.keys(domainlist).forEach(async (domain) => {
      promises.push(
        new Promise(async (resolve, reject) => {
          let id = domainlist[domain];
          if (id) {
            await addDynamicRule(id, domain);
          }
          resolve();
        })
      );
    });
  }


================================================
FILE: src/common/settings.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
settings.js
================================================================================
Shared helpers related to extension settings.
*/

import { storage, stores } from "../background/storage.js";

/**
 * Returns whether the well-known check is enabled.
 * Defaults to true unless explicitly disabled.
 * @returns {Promise<boolean>}
 */
export async function isWellknownCheckEnabled() {
  const enabled = await storage.get(stores.settings, "WELLKNOWN_CHECK_ENABLED");
  return enabled !== false;
}

/**
 * Returns the user's selected state code (CA, CO, CT, NJ) or null if not set.
 * A value of "none" means the user explicitly chose not to be in a covered state.
 * @returns {Promise<string|null>}
 */
export async function getUserState() {
  return await storage.get(stores.settings, "USER_STATE") || null;
}

/**
 * Returns whether the compliance check should be shown.
 * True when a valid state is selected (not null, not "none").
 * @returns {Promise<boolean>}
 */
export async function isComplianceCheckEnabled() {
  const state = await getUserState();
  return state !== null && state !== "none";
}


================================================
FILE: src/content-scripts/contentScript.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
contentScripts.js
================================================================================
contentScripts.js runs on every page and passes data to the background page
https://developer.chrome.com/extensions/content_scripts
*/

// Here is a resource I used to help setup the inject script functionality as
// well as setup message listeners to pass data back to the background
// https://www.freecodecamp.org/news/chrome-extension-message-passing-essentials/

/******************************************************************************/
/******************************************************************************/
/**********              # USPAPI call helper functions              **********/
/******************************************************************************/
/******************************************************************************/


// To be injected to call the USPAPI function in analysis mode
const uspapi = `
  try {
    __uspapi('getUSPData', 1, (data) => {
      let currURL = document.URL
      window.postMessage({ type: "USPAPI_TO_CONTENT_SCRIPT", result: data, url: currURL });
    });
  }
`;

const uspapiRequest = `
  try {
    __uspapi('getUSPData', 1, (data) => {
      let currURL = document.URL
      window.postMessage({ type: "USPAPI_TO_CONTENT_SCRIPT_REQUEST", result: data, url: currURL });
    });
  } catch (e) {
    window.postMessage({ type: "USPAPI_TO_CONTENT_SCRIPT_REQUEST", result: "USPAPI_FAILED" });
  }
`;

function injectScript(script) {
  const scriptElem = document.createElement("script");
  scriptElem.innerHTML = script;
  document.documentElement.prepend(scriptElem);
}

async function isWellknownCheckEnabled() {
  try {
    const { WELLKNOWN_CHECK_ENABLED } = await chrome.storage.local.get(
      "WELLKNOWN_CHECK_ENABLED"
    );
    if (typeof WELLKNOWN_CHECK_ENABLED === "boolean") {
      return WELLKNOWN_CHECK_ENABLED;
    }
  } catch (error) {
    print(error);
  }
  try {
    const response = await chrome.runtime.sendMessage({
      msg: "GET_WELLKNOWN_CHECK_ENABLED",
    });
    if (response && typeof response.enabled === "boolean") {
      return response.enabled;
    }
  } catch (error) {
    print(error);
  }
  // If we can't determine the setting, err on the side of not fetching.
  return false;
}

/******************************************************************************/
/******************************************************************************/
/**********                   # Main functionality                   **********/
/******************************************************************************/
/******************************************************************************/

async function getWellknown(url) {
  const response = await fetch(`${url.origin}/.well-known/gpc.json`);
  new_url = url = JSON.parse(JSON.stringify(url));
  let wellknownData;
  try {
    wellknownData = await response.json();
  } catch {
    wellknownData = null;
  }
  chrome.runtime.sendMessage({
    msg: "CONTENT_SCRIPT_WELLKNOWN",
    data: wellknownData,
    origin_url: new_url
  });
}

/**
 * Passes info to background scripts for processing via messages
 * https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage
 * There are other ways to do this, but I use an IIFE to run everything at once
 * https://developer.mozilla.org/en-US/docs/Glossary/IIFE
 */
(() => {
  /*   MAIN CONTENT SCRIPT PROCESSES GO HERE   */

  let url = new URL(location); // location object
  isWellknownCheckEnabled().then((shouldCheck) => {
    if (shouldCheck) {
      getWellknown(url);
    }
  });
})();

/******************************************************************************/
/******************************************************************************/
/**********    # Message passing from injected script via window     **********/
/******************************************************************************/
/******************************************************************************/

chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { // check unused arguments
  if (message.msg === "USPAPI_FETCH_REQUEST") {
    injectScript(uspapiRequest);
  }
});

window.addEventListener(
  "message",
  function (event) {
    if (
      event.data.type == "USPAPI_TO_CONTENT_SCRIPT"
    ) {
      chrome.runtime.sendMessage({
        msg: "USPAPI_TO_BACKGROUND",
        data: event.data.result,
        location: this.location.href,
      });
    }
    if (event.data.type == "USPAPI_TO_CONTENT_SCRIPT_REQUEST") {
      chrome.runtime.sendMessage({
        msg: "USPAPI_TO_BACKGROUND_FROM_FETCH_REQUEST",
        data: event.data.result,
        location: this.location.href,
      });
    }
  },
  false
);


================================================
FILE: src/content-scripts/injection/gpc-dom.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
injection/gpc-dom.js
================================================================================
injection/gpc-dom.js is the static script injected by a related 
content script (registered from the extension service worker) for full DOM access
*/

/**
 * Sets Global Privacy Control (GPC) JavaScript property on the DOM
 */
function setDomSignal() {
  try {
    var GPCVal = true;
    
    const GPCDomVal = `Object.defineProperties(Navigator.prototype, 
      { "globalPrivacyControl": {
		   get: () => ${GPCVal},
		   configurable: true,
		   enumerable: true
	   }});
    document.currentScript.parentElement.removeChild(document.currentScript);
	   `;

    const GPCDomElem = document.createElement("script");
    GPCDomElem.innerHTML = GPCDomVal;
    document.documentElement.prepend(GPCDomElem);

  } catch (e) {
    console.error(`Failed to set DOM signal: ${e}`);
  }
}

setDomSignal();


================================================
FILE: src/content-scripts/registration/gpc-dom.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
registration/gpc-dom.js
================================================================================
registration/gpc-dom.js is the content script, registered via the 
extension service worker, that injects another static script to provide full
DOM access and permissions
*/

// High Level:
// Static script that will be injected onto a page to allow it full access, not
// an isolated-world access (see Chrome extension API docs on isolated worlds).
// Necessary to inject the GPC JS property on a page via full DOM permission.

// Requirements:
// - INJECTION_SCRIPT must also be defined under "web_accessible_resources"
// - This url must be a (semi) absolute path from the compiled project to the script
//   (Please see webpack output file directory structure)
// - This script must be registered from the extension service worker w/ same URL
const INJECTION_SCRIPT = "content-scripts/injection/gpc-dom.js";

// Based on
// https://stackoverflow.com/questions/9515704/use-a-content-script-to-access-the-page-context-variables-and-functions
function injectStaticScript() {
  let s = document.createElement("script");
  s.src = chrome.runtime.getURL(INJECTION_SCRIPT);
  s.online = function () {
    this.remove();
  };
  document.documentElement.prepend(s);
}
injectStaticScript();


================================================
FILE: src/data/complianceData.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
complianceData.js
================================================================================
Fetches and processes GPC compliance data from state-specific hosted CSV files.
CSV URLs are read dynamically from states.json hosted on GitHub so they can be
updated server-side without requiring an extension update.

Compliance is determined by set membership and signal content:
  - Domain in noncompliant_sites        → 'non_compliant'
  - Domain in all_sites, signals found  → 'compliant'
  - Domain in all_sites, all signals null (nothing to measure against)   → 'no_signals'
  - Domain in neither                   → 'no_data'  (handled by caller)
  - Network/server error                → 'fetch_error' (handled by caller)

The 8 signal columns checked for null:
  uspapi_before_gpc, uspapi_after_gpc,
  usp_cookies_before_gpc, usp_cookies_after_gpc,
  OptanonConsent_before_gpc, OptanonConsent_after_gpc,
  gpp_before_gpc, gpp_after_gpc

When the all_sites CSV includes a `compliance_classification` column (per the
schema in gpc-web-ui at client/background_reading/COMPLIANCE_CLASSIFICATION_OVERVIEW.md
— https://github.com/privacy-tech-lab/gpc-web-ui/blob/master/client/background_reading/COMPLIANCE_CLASSIFICATION_OVERVIEW.md),
the parsed JSON object is attached to each domain entry as `classification` so
the popup can show per-family status (USPS, OptanonConsent, Well-known, GPP).
*/

const STATES_JSON_URL =
  'https://raw.githubusercontent.com/privacy-tech-lab/gpc-web-ui/master/client/public/states.json'; // Permalink to raw states.json — use raw.githubusercontent.com so fetch() gets JSON, not an HTML page

// Human-readable state names (used to look up entries in states.json)
export const STATE_NAMES = {
  CA: 'California',
  CO: 'Colorado',
  CT: 'Connecticut',
  NJ: 'New Jersey',
};



// Cache TTL: 24 hours
const CACHE_TTL_MS = 24 * 60 * 60 * 1000;

/**
 * Converts a GitHub blob URL to a raw.githubusercontent.com URL so fetch()
 * receives the raw file content rather than an HTML page.
 * e.g. https://github.com/ORG/REPO/blob/SHA/path/file.csv
 *   →  https://raw.githubusercontent.com/ORG/REPO/SHA/path/file.csv
 * @param {string} blobUrl
 * @returns {string}
 */
function toRawUrl(blobUrl) {
  // Handle GitHub blob URLs
  const githubMatch = blobUrl.match(
    /^https:\/\/github\.com\/([^/]+\/[^/]+)\/blob\/(.+)$/
  );
  if (githubMatch) {
    return `https://raw.githubusercontent.com/${githubMatch[1]}/${githubMatch[2]}`;
  }
  // If it's already a raw URL or something else, return as-is
  return blobUrl;
}

/**
 * Fetches states.json from the remote host to retrieve current CSV URLs.
 * @returns {Promise<Object>} - Parsed states.json content
 */
async function fetchStatesConfig() {
  const response = await fetch(STATES_JSON_URL);
  if (!response.ok) {
    throw new Error(`Failed to fetch states.json (${response.status})`);
  }
  return response.json();
}

// The 8 privacy-signal column names we check for in all_sites
const SIGNAL_COLUMNS = [
  'uspapi_before_gpc',
  'uspapi_after_gpc',
  'usp_cookies_before_gpc',
  'usp_cookies_after_gpc',
  'optanonconsent_before_gpc',
  'optanonconsent_after_gpc',
  'gpp_before_gpc',
  'gpp_after_gpc',
];

/**
 * Returns true if a column value counts as "null" (no signal present).
 * @param {string|undefined} val
 * @returns {boolean}
 */
function isNullSignal(val) {
  return !val || val.trim() === '' || val.trim().toLowerCase() === 'null';
}

/**
 * Parses a single CSV line, honoring double-quote-wrapped fields with `""`
 * escapes. Required because some columns (urlClassification, third_party_urls,
 * compliance_classification, …) contain quoted JSON with embedded commas.
 * Naive `line.split(',')` mis-aligns columns past the first quoted field.
 * Assumes no embedded newlines inside quoted fields, which holds for these CSVs.
 * @param {string} line
 * @returns {string[]}
 */
function parseCSVLine(line) {
  const out = [];
  let cur = '';
  let inQuotes = false;
  for (let i = 0; i < line.length; i++) {
    const ch = line[i];
    if (inQuotes) {
      if (ch === '"') {
        if (line[i + 1] === '"') { cur += '"'; i++; }
        else { inQuotes = false; }
      } else {
        cur += ch;
      }
    } else if (ch === ',') {
      out.push(cur); cur = '';
    } else if (ch === '"' && cur === '') {
      inQuotes = true;
    } else {
      cur += ch;
    }
  }
  out.push(cur);
  return out;
}

/**
 * Parses the `compliance_classification` field, which the upstream crawler
 * currently emits as a Python repr (single quotes, None/True/False) rather
 * than real JSON. We coerce to JSON before parsing so the field is usable.
 * Returns null if the value can't be parsed under either dialect.
 *
 * TODO: the blind `'` → `"` replace will mangle any string value that contains
 * an apostrophe. Today the schema only carries enum statuses with no free-form
 * strings, so this is safe, but the real fix is upstream: have the crawler
 * emit real JSON (json.dumps) instead of a Python repr in this column.
 * @param {string} raw
 * @returns {object|null}
 */
function parseClassification(raw) {
  try { return JSON.parse(raw); } catch (_) {}
  const jsonish = raw
    .replace(/\bNone\b/g, 'null')
    .replace(/\bTrue\b/g, 'true')
    .replace(/\bFalse\b/g, 'false')
    .replace(/'/g, '"');
  try { return JSON.parse(jsonish); } catch (_) { return null; }
}

/**
 * Fetches a CSV from the given URL and returns a Set of domain strings.
 * Used for the noncompliant_sites CSV where we only need domain membership.
 * Assumes a column header named "domain" (case-insensitive).
 * @param {string} url - Direct download URL for the CSV
 * @returns {Promise<Set<string>>} - Set of domain names found in the CSV
 */
async function fetchDomainSet(url) {
  const response = await fetch(url);
  if (!response.ok) {
    throw new Error(`Failed to fetch CSV (${response.status}): ${url}`);
  }

  const csvText = await response.text();

  if (csvText.trim().startsWith('<!DOCTYPE html>') || csvText.includes('Google Drive - Virus scan warning')) {
    throw new Error('CSV fetch returned HTML (possible Google Drive virus-scan redirect)');
  }

  const lines = csvText.split(/\r?\n/);
  if (lines.length < 2) return new Set();

  // Find the index of the "domain" column from the header row
  const headers = lines[0].split(',').map(h => h.trim().toLowerCase());
  const domainIndex = headers.indexOf('domain');
  if (domainIndex === -1) {
    throw new Error('CSV does not contain a "domain" column');
  }

  const domains = new Set();
  for (let i = 1; i < lines.length; i++) {
    const line = lines[i].trim();
    if (!line) continue;
    // Simple split — domain names don't contain commas or quotes
    const cols = line.split(',');
    const domain = cols[domainIndex] ? cols[domainIndex].trim() : null;
    if (domain) {
      domains.add(domain);
    }
  }

  return domains;
}

/**
 * Fetches the all_sites CSV and returns a Map of domain →
 *   { allNull: boolean, classification: object|null }.
 * - allNull is true when all 8 privacy-signal columns are null/empty, meaning
 *   we could not observe any consent mechanism to measure GPC compliance against.
 * - classification is the parsed `compliance_classification` JSON object when
 *   the column is present and parseable, otherwise null.
 * @param {string} url - Direct download URL for the all_sites CSV
 * @returns {Promise<Map<string, {allNull: boolean, classification: object|null}>>}
 */
async function fetchAllSitesData(url) {
  const response = await fetch(url);
  if (!response.ok) {
    throw new Error(`Failed to fetch CSV (${response.status}): ${url}`);
  }

  const csvText = await response.text();

  if (csvText.trim().startsWith('<!DOCTYPE html>') || csvText.includes('Google Drive - Virus scan warning')) {
    throw new Error('CSV fetch returned HTML (possible Google Drive virus-scan redirect)');
  }

  const lines = csvText.split(/\r?\n/);
  if (lines.length < 2) return new Map();

  const headers = parseCSVLine(lines[0]).map(h => h.trim().toLowerCase());
  const domainIndex = headers.indexOf('domain');
  if (domainIndex === -1) {
    throw new Error('all_sites CSV does not contain a "domain" column');
  }

  // Map each signal column name to its index (-1 if not present)
  const signalIndices = SIGNAL_COLUMNS.map(col => headers.indexOf(col));
  const classificationIndex = headers.indexOf('compliance_classification');

  const result = new Map();
  for (let i = 1; i < lines.length; i++) {
    const line = lines[i];
    if (!line || !line.trim()) continue;
    const cols = parseCSVLine(line);
    const domain = cols[domainIndex] ? cols[domainIndex].trim() : null;
    // Skip rows where domain itself is missing or the literal string "null"
    // (happens when the crawler couldn't resolve the domain, e.g. status="not added")
    if (!domain || domain.toLowerCase() === 'null') continue;

    // A domain is allNull only if every signal column is null/empty
    const allNull = signalIndices.every(idx => idx === -1 || isNullSignal(cols[idx]));

    let classification = null;
    if (classificationIndex !== -1) {
      const raw = cols[classificationIndex];
      if (raw && raw.trim() && raw.trim().toLowerCase() !== 'null') {
        classification = parseClassification(raw);
      }
    }

    result.set(domain, { allNull, classification });
  }

  return result;
}

/**
 * Fetches and processes compliance data for a specific state.
 * First fetches states.json from the remote host to get current CSV URLs,
 * then fetches both all_sites and noncompliant_sites CSVs in parallel.
 * Determines status by set membership and signal content:
 *   - in noncompliant_sites              → 'non_compliant'
 *   - in all_sites, signals detected     → 'compliant'
 *   - in all_sites, all signals null     → 'no_signals'
 * Domains absent from all_sites are not included in the returned map;
 * the caller treats missing entries as 'no_data'.
 * Any network or server error returns { error: 'fetch_error' }.
 *
 * @param {string} stateCode - Two-letter state code (CA, CO, CT, NJ)
 * @returns {Promise<Object>} - { data, fetchedAt, stateCode, count } or { error: 'fetch_error' }
 */
export async function fetchComplianceData(stateCode) {
  const stateName = STATE_NAMES[stateCode];
  if (!stateName) {
    throw new Error(`Unknown state code: ${stateCode}`);
  }

  // Fetch states.json from the remote host to get current CSV URLs
  let statesConfig;
  try {
    statesConfig = await fetchStatesConfig();
  } catch (error) {
    console.error('Could not reach states.json config server:', error);
    return { error: 'fetch_error' };
  }

  const stateEntry = statesConfig[stateName];
  if (!stateEntry || !stateEntry.all_sites || !stateEntry.noncompliant_sites) {
    console.error(`states.json does not contain a valid entry for: ${stateName}`);
    return { error: 'fetch_error' };
  }

  // Convert GitHub blob URLs from states.json to raw content URLs
  let allSitesUrl, noncompliantUrl;
  try {
    allSitesUrl = toRawUrl(stateEntry.all_sites);
    noncompliantUrl = toRawUrl(stateEntry.noncompliant_sites);
  } catch (error) {
    console.error('Failed to parse CSV URLs from states.json:', error);
    return { error: 'fetch_error' };
  }

  console.log(`Fetching ${stateCode} compliance data (all_sites + noncompliant_sites)...`);

  let allSitesData, noncompliantDomains;
  try {
    [allSitesData, noncompliantDomains] = await Promise.all([
      fetchAllSitesData(allSitesUrl),
      fetchDomainSet(noncompliantUrl),
    ]);
  } catch (error) {
    console.error(`Failed to fetch compliance CSVs for ${stateCode}:`, error);
    return { error: 'fetch_error' };
  }

  console.log(`${stateCode}: ${allSitesData.size} all_sites, ${noncompliantDomains.size} noncompliant_sites`);

  const complianceMap = {};

  for (const [domain, { allNull, classification }] of allSitesData) {
    let status;
    if (noncompliantDomains.has(domain)) {
      status = 'non_compliant';
    } else if (allNull) {
      // All 8 signal columns were null during the crawl — we can't assess compliance
      status = 'no_signals';
    } else {
      status = 'compliant';
    }
    complianceMap[domain] = {
      status,
      details: '',
      classification, // null when CSV lacks the column or value is JSON null
    };
  }

  return {
    data: complianceMap,
    fetchedAt: Date.now(),
    stateCode,
    count: Object.keys(complianceMap).length,
    // The view URL for this state's all_sites dataset (from states.json)
    viewUrl: stateEntry.all_sites,
  };
}

/**
 * Checks if cached data is still valid
 * @param {number} fetchedAt - Timestamp when data was fetched
 * @returns {boolean} - True if cache is still valid
 */
export function isCacheValid(fetchedAt) {
  if (!fetchedAt) return false;
  return (Date.now() - fetchedAt) < CACHE_TTL_MS;
}


================================================
FILE: src/data/defaultSettings.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
defaultSettings.js 
================================================================================
defaultSettings.js exports the default global extension settings
*/

export const defaultSettings = {
  BROWSER: "$BROWSER",
  DOMAINLIST_PRESSED: false,
  IS_DOMAINLISTED: false,
  IS_ENABLED: true,
  TUTORIAL_SHOWN: true,
  REQUEST_PERMISSIONS_SHOWN: false,
  TUTORIAL_SHOWN_IN_POPUP: true,
  WELLKNOWN_CHECK_ENABLED: true,
  COMPLIANCE_CHECK_ENABLED: true,
};


================================================
FILE: src/data/headers.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
headers.js
================================================================================
headers.js exports all opt-out headers to be attached per request
*/

// headers must contain a name and a value
export const headers = {
  "Sec-GPC": {
    name: "Sec-GPC",
    value: "1",
  },
  "Disable-Topics": {
    name: 'permissions-policy',
    value: 'interest-cohort=()'
  }
};


================================================
FILE: src/manifests/chrome/manifest-dev.json
================================================
{
  "name": "OptMeowt",
  "author": "privacy-tech-lab",
  "version": "6.1.0",
  "description": "OptMeowt allows Web users to make use of their rights to opt out from the sale and sharing of personal data",
  "permissions": [
    "declarativeNetRequest",
    "webRequest",
    "webNavigation",
    "storage",
    "activeTab",
    "tabs",
    "scripting"
  ],
  "declarative_net_request": {
    "rule_resources": [
      {
        "id": "universal_GPC",
        "enabled": true,
        "path": "rules/universal_gpc_rules.json"
      },
      {
        "id": "GPC_exceptions",
        "enabled": true,
        "path": "rules/gpc_exceptions_rules.json"
      }
    ]
  },
  "host_permissions": [
    "<all_urls>"
  ],
  "icons": {
    "128": "assets/face-icons/icon128-face-circle.png"
  },
  "action": {
    "default_title": "OptMeowt",
    "default_popup": "popup.html"
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["content-scripts/contentScript.js"],
      "run_at": "document_start"
    }
  ],
  "options_ui": {
    "page": "options.html",
    "open_in_tab": true
  },
  "background": {
    "service_worker": "background.bundle.js"
  },
  "web_accessible_resources": [{
	  "resources": ["content-scripts/injection/gpc-dom.js"],
	  "matches": ["<all_urls>"]
	}],
  "manifest_version": 3,
  "incognito": "spanning",
  "content_security_policy": {
    "extension_pages": "script-src 'self'; object-src 'self'",
    "sandbox": "sandbox allow-scripts; script-src 'self' 'unsafe-eval'; object-src 'self'"
  }
}


================================================
FILE: src/manifests/chrome/manifest-dist.json
================================================
{
  "name": "OptMeowt",
  "author": "privacy-tech-lab",
  "version": "6.1.0",
  "description": "OptMeowt allows Web users to make use of their rights to opt out from the sale and sharing of personal data",
  "permissions": [
    "declarativeNetRequest",
    "webRequest",
    "webNavigation",
    "storage",
    "activeTab",
    "tabs",
    "scripting"
  ],
  "declarative_net_request": {
    "rule_resources": [
      {
        "id": "universal_GPC",
        "enabled": true,
        "path": "rules/universal_gpc_rules.json"
      },
      {
        "id": "GPC_exceptions",
        "enabled": true,
        "path": "rules/gpc_exceptions_rules.json"
      }
    ]
  },
  "host_permissions": [
    "<all_urls>"
  ],
  "icons": {
    "128": "assets/face-icons/icon128-face-circle.png"
  },
  "action": {
    "default_title": "OptMeowt",
    "default_popup": "popup.html"
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["content-scripts/contentScript.js"],
      "run_at": "document_start"
    }
  ],
  "options_ui": {
    "page": "options.html",
    "open_in_tab": true
  },
  "background": {
    "service_worker": "background.bundle.js"
  },
  "web_accessible_resources": [{
	  "resources": ["content-scripts/injection/gpc-dom.js"],
	  "matches": ["<all_urls>"]
	}],
  "manifest_version": 3,
  "incognito": "spanning",
  "content_security_policy": {
    "extension_pages": "script-src 'self'; object-src 'self'",
    "sandbox": "sandbox allow-scripts; script-src 'self' 'unsafe-eval'; object-src 'self'"
  }
}


================================================
FILE: src/manifests/firefox/manifest-dev.json
================================================
{
  "name": "OptMeowt",
  "author": "privacy-tech-lab",
  "version": "6.1.0",
  "description": "OptMeowt allows Web users to make use of their rights to opt out from the sale and sharing of personal data",
  "permissions": [
    "webRequestBlocking",
    "declarativeNetRequest",
    "webRequest",
    "webNavigation",
    "storage",
    "activeTab",
    "tabs",
    "scripting"
  ],
  "declarative_net_request": {
    "rule_resources": [
      {
        "id": "universal_GPC",
        "enabled": true,
        "path": "rules/universal_gpc_rules.json"
      },
      {
        "id": "GPC_exceptions",
        "enabled": true,
        "path": "rules/gpc_exceptions_rules.json"
      }
    ]
  },
  "host_permissions": [
    "<all_urls>"
  ],
  "icons": {
    "128": "assets/face-icons/icon128-face-circle.png"
  },
  "action": {
    "default_title": "OptMeowt",
    "default_popup": "popup.html"
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["content-scripts/contentScript.js"],
      "run_at": "document_start"
    }
  ],
  "options_ui": {
    "page": "options.html",
    "open_in_tab": true
  },
  "background": {
    "scripts": ["background.bundle.js"]
  },
  "web_accessible_resources": [{
	  "resources": ["content-scripts/injection/gpc-dom.js"],
	  "matches": ["<all_urls>"]
	}],
  "manifest_version": 3,
  "incognito": "spanning",
  "content_security_policy": {
    "extension_pages": "script-src 'self'; object-src 'self'"
  },
  "browser_specific_settings": {
    "gecko": {
      "id": "{7f22397f-fb61-47e2-9e4b-4ddd98faa275}"
    }
  }
}


================================================
FILE: src/manifests/firefox/manifest-dist.json
================================================
{
  "name": "OptMeowt",
  "author": "privacy-tech-lab",
  "version": "6.1.0",
  "description": "OptMeowt allows Web users to make use of their rights to opt out from the sale and sharing of personal data",
  "permissions": [
    "webRequestBlocking",
    "declarativeNetRequest",
    "webRequest",
    "webNavigation",
    "storage",
    "activeTab",
    "tabs",
    "scripting"
  ],
  "declarative_net_request": {
    "rule_resources": [
      {
        "id": "universal_GPC",
        "enabled": true,
        "path": "rules/universal_gpc_rules.json"
      },
      {
        "id": "GPC_exceptions",
        "enabled": true,
        "path": "rules/gpc_exceptions_rules.json"
      }
    ]
  },
  "host_permissions": [
    "<all_urls>"
  ],
  "icons": {
    "128": "assets/face-icons/icon128-face-circle.png"
  },
  "action": {
    "default_title": "OptMeowt",
    "default_popup": "popup.html"
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["content-scripts/contentScript.js"],
      "run_at": "document_start"
    }
  ],
  "options_ui": {
    "page": "options.html",
    "open_in_tab": true
  },
  "background": {
    "scripts": ["background.bundle.js"]
  },
  "web_accessible_resources": [{
	  "resources": ["content-scripts/injection/gpc-dom.js"],
	  "matches": ["<all_urls>"]
	}],
  "manifest_version": 3,
  "incognito": "spanning",
  "content_security_policy": {
    "extension_pages": "script-src 'self'; object-src 'self'"
  },
  "browser_specific_settings": {
    "gecko": {
      "id": "{7f22397f-fb61-47e2-9e4b-4ddd98faa275}"
    }
  }
}


================================================
FILE: src/options/components/scaffold-component.html
================================================
<!--
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
-->

<!--
scaffold-component.html
================================================================================
scaffold-component.html defines the layout of each scrollable content
-->

<!--
    This template is passed into every subpage in the options page via
    the given JS function. The correct information for each page is inflated
    in the sections below, and then the newly filled scaffold template is
    passed into the options page and rendered.
 -->
<template id="scaffold-component">
  <div class="uk-container" id="scaffold" style="animation-duration: 250ms">
    <div class="uk-grid-large">
      <!-- Heading and subtitle -->
      <div class="first-column uk-margin-medium-bottom">
        <h1 class="uk-heading-medium text-color-darker" style="display: inline">
          {{ title }}
        </h1>
        <div class="uk-text-lead uk-text-light text-color">{{ subtitle }}</div>
      </div>
      <!-- Body -->
      <div class="first-column" id="scaffold-component-body">
        <!-- Body content inflated here -->
      </div>
    </div>
  </div>
</template>


================================================
FILE: src/options/components/util.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
util.js
================================================================================
util.js contains global helper functions to help render the options page
*/

/**
 * Get local html file as string
 * @param {string} path - location of HTML template
 * @returns {string|none} - Returns the stringified HTML template or
 *                          prints an error
 */
import Mustache from "mustache";

export async function fetchTemplate(path) {
  let response = await fetch(path);
  let data = await response.text();
  return data;
}

/**
 * Parse string to html document
 * @param {string} template - stringified HTML template
 * @returns {HTMLDocument} - also a Document
 */
export function parseTemplate(template) {
  let parser = new DOMParser();
  let doc = parser.parseFromString(template, "text/html");
  return doc;
}

/**
 * Fetches and parses html document; returns selected html
 * @param {string} path - location of document to be parsed
 * @param {string} id - name of the element in doc to be selected
 *                      after it is parsed
 * @returns {Object} - element object related to the id parameter
 */
export async function fetchParse(path, id) {
  let template = await fetchTemplate(path);
  return parseTemplate(template).getElementById(id);
}

/**
 * Renders and parse html document; returns selected html
 * @param {string} template - stringified HTML doc template
 * @param {Object} data - specifically a `headings` object
 * @param {string} id - id of an element in an HTML doc
 * @returns {Object} - element object related to the id parameter
 */
export function renderParse(template, data, id) {
  let renderedTemplate = Mustache.render(template, data);
  return parseTemplate(renderedTemplate).getElementById(id);
}


================================================
FILE: src/options/dark-mode.css
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

.darkmode--activated {
  background-color: #252522 !important;
  color: #eee !important;
}

.darkmode--activated .bg-light {
  background-color: #333 !important;
}

.darkmode--activated .bg-white {
  background-color: #111 !important;
}

.darkmode--activated .bg-black {
  background-color: #eee !important;
}

.darkmode--activated .text-color-darker {
  color: #dddddd !important;
}

.darkmode--activated .text-color {
  color: #adadad !important;
}

.darkmode--activated .question {
  color: #dddddd !important;
}

.darkmode--activated .answer {
  color: #adadad !important;
}

.darkmode--activated .divide {
  color: #ffff00 !important;
}

.darkmode--activated .uk-list-divide {
  color: #ffff00 !important;
}

.darkmode--activated .blue-heading {
  color: #93caf2 !important;
}

.darkmode--activated a {
  text-decoration: underline;
  color: #fff !important;
}

.darkmode--activated .uk-modal-body,
.darkmode--activated .uk-modal-footer,
.darkmode--activated .uk-modal-header {
  background-color: #252522 !important;
}

/********************************************************/

/*
Radio buttons style settings page
*/
.darkmode--activated input[type="radio"] {
  width: 35px;
  height: 35px;
  transition: all ease 0.5s;
}

.darkmode--activated input[type="radio"]:checked {
  transition: all ease 0.25s;
  background-image: var(--accent-color);
  box-shadow: 0 6px 12px #222221;
}

.darkmode--activated input[type="radio"]:hover:not(:checked) {
  transition: all ease 0.25s;
  box-shadow: 0 6px 12px #222221;
  background-color: #cbcbcb;
  /* border-color: transparent; */
}

/*
Settings page
*/
.darkmode--activated .navbar-item.active {
  color: #3d87e9;
}

/*
'settings-view' domainlist import & export button style
*/
.darkmode--activated .importexport-button {
  background-color: #252522 !important;
  border-color: #cbcbcb !important;
  color: #cbcbcb !important;
  box-shadow: 0 8px 16px -1px #111111 !important;
}
.darkmode--activated .importexport-button:hover {
  background-color: #d4d4d4 !important;
  border-color: #d4d4d4 !important;
  color: #4e4e4d !important;
  box-shadow: 0 6px 12px #303030 !important;
}

.darkmode--activated .domainlist-navbar {
  background-color: #252522 !important;
  color: #cbcbcb !important;
}

.darkmode--activated .analysis-navbar {
  background-color: #252522 !important;
  color: #cbcbcb !important;
}

.darkmode--activated .sticky {
  box-shadow: 0 8px 8px -10px #111111 !important;
}

/********************************************************/

/*
Buttons and Switches
*/

.darkmode--activated .optMode {
  border: 1px solid rgb(238, 238, 238);
  color: rgb(238, 238, 238);
  box-shadow: 0 3px 6px -1px #111111 !important;
}

.darkmode--activated .optMode:hover {
  color: var(--text-white) !important;
}

.darkmode--activated .search {
  background-color: #333 !important;
  border-color: #333 !important;
  color: #cbcbcb;
}

.darkmode--activated .button {
  background-color: rgb(70, 70, 70) !important;
  border: 1px solid rgb(70, 70, 70) !important;
  transition: all 0.3s ease;
  color: #eee !important;
}

.darkmode--activated .uk-badge {
  background-color: rgb(37, 37, 34) !important;
}

.darkmode--activated .button:hover {
  background-color: rgb(143, 17, 17) !important;
  border: 1px solid rgb(143, 17, 17) !important;
  transition: all 0.3s ease;
  color: #eee !important;
}

.darkmode--activated .switch input:checked + span {
  background: #37be70 !important;
  box-shadow: 0 0px 0px 0px rgba(72, 234, 139, 0.2) !important;
}

.darkmode--activated .switch input + span {
  box-shadow: 0 0px 0px 0px rgba(72, 234, 139, 0.2) !important;
}

.darkmode--activated .domain-list:hover {
  background-color: #5f5f5d !important;
  color: white !important;
}

.darkmode--activated .dropdown-tab:hover {
  background-color: #3f3f3c !important;
  color: #eee !important;
}

.darkmode--activated .dropdown-tab-click {
  background-color: #3f3f3c !important;
  color: #eee !important;
}

.darkmode--activated .wellknown-bg {
  background-color: #3f3f3c !important;
  border-color: #3f3f3c !important;
  color: #eeeeee;
}

/* .darkmode--activated .dark-checkbox {
  background-color: #333 !important;
  border: 1px solid #333 !important;
  color: #eee !important;
} */

/* input[type="radio"]:checked, .darkmode--activated {
  box-shadow: 0 6px 12px #000 !important;
}
input[type='radio']:hover:not(:checked), .darkmode--activated {
  box-shadow: 0 6px 12px #000 !important;
} */


================================================
FILE: src/options/options.html
================================================
<!--
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
-->

<!--
options.html
================================================================================
options.html is the html scaffolding for OptMeowt's options page
-->

<!--
    This is the bare bones options.html page before the `main view` is
    loaded and before any main content is loaded.
-->
<!DOCTYPE html>
<html>
  <head>
    <title>OptMeowt</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>

  <!-- This is the entry point to 'Options' -->

  <body>
    <!-- Content will be inflated here-->
  </body>
</html>


================================================
FILE: src/options/options.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
options.js
================================================================================
options.js starts the process of rendering the main options page
*/

import { mainView } from "./views/main-view/main-view.js";

// CSS TO JS IMPORTS
import "../../node_modules/uikit/dist/css/uikit.min.css";
import "../../node_modules/animate.css/animate.min.css";
import "./styles.css";

// HTML TO JS IMPORTS - TOP OF `popup.html`
import "../../node_modules/uikit/dist/js/uikit.js";
import "../../node_modules/uikit/dist/js/uikit-icons.js";
import "../../node_modules/mustache/mustache.js";
import "../../node_modules/@popperjs/core/dist/umd/popper.js";
import "../../node_modules/tippy.js/dist/tippy-bundle.umd.js";

/**
 * Intializes scripts that build the options page
 */
document.addEventListener("DOMContentLoaded", (event) => {
  mainView(); // check event
});


================================================
FILE: src/options/styles.css
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
styles.css
================================================================================
styles.css is the main css page for OptMeowt's options page
*/

@import "./dark-mode.css";

/********************************************************/

/*
Colors
*/
:root {
  --accent-color: #4472c4;
  --accent-color-lighter-80: #dae3f3;
  --accent-color-lighter-60: #b4c7e7;
  --accent-color-lighter-40: #8faadc;
  --accent-color-darker-25: #2f5597;
  --accent-color-darker-50: #203864;

  /* --text-color: #888fa1; */
  --text-color: #5a647d;
  /* --text-color-darker: #5a647d ; */
  --text-color-darker: #353b4a;
  --text-color-inactive: #d3d3d3;

  --highlight-light: #f2f2f2;

  --text-gray: rgb(89, 98, 127);
}

.text-color-darker {
  color: var(--text-color-darker);
}

.text-color {
  color: var(--text-color);
}

/********************************************************/

/*
Body style
*/
html {
  background-color: inherit;
}

body {
  color: var(--text-color);
  user-select: none;
}

pre,
code {
  white-space: pre-line;
}

a {
  text-decoration: underline;
}

/********************************************************/

/*
About page Q/A heading style
*/
.question {
  color: var(--text-color-darker);
  font-size: x-large;
  user-select: none;
}

.answer {
  color: var(--text-color);
  font-size: medium;
  user-select: none;
}

/********************************************************/

/*
Navbar item style
*/
.navbar-item {
  color: var(--text-color-inactive);
  opacity: 1;
  cursor: pointer;
  transition: all ease 0.5s;
}

.navbar-item.active {
  color: var(--accent-color);
}

/********************************************************/

/*
Sticky Domain List Navbar
*/
.domainlist-navbar {
  background-color: white;
  padding-top: 5px;
}
/*
Sticky Analysis List Navbar
*/

/* Added with  */
.sticky {
  position: fixed;
  top: 0;
  width: 100%;
  transition: all ease 0.25s;
  box-shadow: 0 8px 8px -10px var(--accent-color-lighter-60);
  z-index: 100;
}

/********************************************************/

/*
Radio buttons style
*/
input[type="radio"] {
  width: 35px;
  height: 35px;
  transition: all ease 0.5s;
}

input[type="radio"]:checked {
  transition: all ease 0.25s;
  background-image: var(--accent-color);
  box-shadow: 0 4px 8px var(--accent-color-lighter-60);
}

input[type="radio"]:hover:not(:checked) {
  transition: all ease 0.25s;
  box-shadow: 0 4px 8px var(--accent-color-lighter-60);
  border-color: transparent;
}

/********************************************************/

/*
`domainlist-view` options page checkbox style
*/
.check {
  /* appearance: none; */
  transform: scale(1.25);
  /* transform-style: inherit; */
  /* z-index: -10; */
}

/********************************************************/

/*
'settings-view' domainlist import & export button style
*/
.importexport-button {
  background-color: white;
  border-color: #888fa1;
  color: #888fa1;
  padding: 12px 16px;
  text-align: center;
  text-decoration-color: none;
  font-size: 14px;
  display: inline-block;
  border-radius: 10px;
  border-style: solid;
  box-shadow: 0 8px 16px -1px rgba(211, 211, 211, 0.2);
  outline: none;
  transition: all ease 0.25s;
}
.importexport-button:hover {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  color: white;
  box-shadow: 0 6px 12px var(--accent-color-lighter-60);
  transition: all ease 0.25s;
}

.button:hover {
  background-color: #df3131 !important;
  border: 1px solid #df3131 !important;
  transition: all 0.3s ease;
  color: #fff !important;
}

.uspStringElem {
  margin: auto;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-right: 8px;
  padding-left: 8px;
  background-color: white;
  border: 1px solid var(--text-gray);
  color: var(--text-gray);
  text-align: center;
}

.uspStringElem:hover {
  background-color: white;
  border: 1px solid var(--text-gray);
  color: var(--text-gray);
}

.uspStringElem:active {
  background-color: white;
  border: 1px solid var(--text-gray);
  color: var(--text-gray);
}

/********************************************************/

/* Animated iOS style switch
https://codepen.io/aaroniker/pen/oaQdQZ
*/
.switch {
  cursor: pointer;
}
.switch input {
  display: none;
}
.switch input + span {
  width: 48px;
  height: 28px;
  border-radius: 14px;
  transition: all 0.3s ease;
  display: block;
  position: relative;
  background: #888fa1;
  box-shadow: 0 8px 16px -1px rgba(211, 211, 211, 0.2);
}
.switch input + span:before,
.switch input + span:after {
  content: "";
  display: block;
  position: absolute;
  transition: all 0.3s ease;
}
.switch input + span:before {
  top: 5px;
  left: 5px;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  border: 5px solid #fff;
}
.switch input + span:after {
  top: 5px;
  left: 32px;
  width: 6px;
  height: 18px;
  border-radius: 40%;
  transform-origin: 50% 50%;
  background: #fff;
  opacity: 0;
}
.switch input + span:active {
  transform: scale(0.92);
}
.switch input:checked + span {
  background: #48ea8b;
  box-shadow: 0 8px 16px -1px rgba(72, 234, 139, 0.2);
}
.switch input:checked + span:before {
  width: 0px;
  border-radius: 3px;
  margin-left: 27px;
  border-width: 3px;
  background: #fff;
}
.switch input:checked + span:after {
  animation: blobChecked 0.35s linear forwards 0.2s;
}
.switch input:not(:checked) + span:before {
  animation: blob 0.85s linear forwards 0.2s;
}
@keyframes blob {
  0%,
  100% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.12, 0.94);
  }
  60% {
    transform: scale(0.96, 1.06);
  }
}
@keyframes blobChecked {
  0% {
    opacity: 1;
    transform: scaleX(1);
  }
  30% {
    transform: scaleX(1.44);
  }
  70% {
    transform: scaleX(1.18);
  }
  50%,
  99% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0;
  }
}
* {
  box-sizing: border-box;
}
*:before,
*:after {
  box-sizing: border-box;
}

*:before,
*:after {
  box-sizing: border-box;
}

.switch-smaller input + span {
  width: 48px;
  height: 28px;
  border-radius: 14px;
  transition: all 0.3s ease;
  display: block;
  position: relative;
  background: #888fa1;
  box-shadow: 0 8px 16px -1px rgba(211, 211, 211, 0.2);
  transform: scale(0.7);
}
.switch-smaller input + span:active {
  transform: scale(0.65);
}

/*========================================================================================*/
/*Walkthrough popups css*/

.tippy-box[data-theme~="custom-1"] {
  background-color: #87cefa;
  box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.43);
  color: white;
  border-radius: 5px;
  padding: 10px;
  text-align: left;
  float: left;
}

.tippy-box[data-theme~="custom-1"] button {
  color: white;
}

.tippy-box[data-theme~="custom-1"][data-placement^="top"]
  > .tippy-arrow::before {
  border-top-color: #87cefa;
}
.tippy-box[data-theme~="custom-1"][data-placement^="bottom"]
  > .tippy-arrow::before {
  border-bottom-color: #87cefa;
}
.tippy-box[data-theme~="custom-1"][data-placement^="left"]
  > .tippy-arrow::before {
  border-left-color: #87cefa;
}
.tippy-box[data-theme~="custom-1"][data-placement^="right"]
  > .tippy-arrow::before {
  border-right-color: #87cefa;
}


================================================
FILE: src/options/views/about-view/about-view.html
================================================
<!--
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
-->


<!--
about-view.html
================================================================================
about-view.html contains the 'about' view template to be loaded into the
options page when clicked
-->


<!--
    This is the body content inflated into scaffold-component.html when
    the `about view` is called by a user from within the options page.
-->
<template id="about-view">
  <div>
    <p class="uk-width-3-4" style="font-size: medium;">
      OptMeowt ("Opt Me Out") 🐾 is a browser extension for sending
      Global Privacy Control signals to websites that you visit.
      It is part of [Global Privacy Control](https://globalprivacycontrol.org/),
      a Global Privacy Control standardization effort we are spearheading.
    </br></br>
      Feel free to read more about how OptMeowt works in our
      <a href="https://github.com/privacy-tech-lab/gpc-optmeowt">GitHub repo</a>.
    </p>

    <p class="uk-width-3-4 question">
      <b>Do I need an account to use OptMeowt?</b>
    </p>
    <p class="uk-width-3-4 answer">
      You do not need an account to use OptMeowt.
    </p>

    <p class="uk-width-3-4 question">
      <b>How do I update OptMeowt?</b>
    </p>
    <p class="uk-width-3-4 answer">
      If you installed OptMeowt via the <a href="https://chrome.google.com/webstore/detail/optmeowt/hdbnkdbhglahihjdbodmfefogcjbpgbo">Google Chrome Web Store</a> or as a 
      <a href="https://addons.mozilla.org/en-US/firefox/addon/optmeowt/">Firefox Browser Add-on</a>,
      updates should be pushed automatically to you. We will also push updates
      regularly to <a href="https://github.com/privacy-tech-lab/gpc-optmeowt">
      OptMeowt's GitHub repo</a>. 
    </p>

    <p class="uk-width-3-4 question">
      <b>Who are you?</b>
    </p>
    <p class="uk-width-3-4 answer">
      We are academic researchers at
      <a href="https://privacytechlab.org/">
        Wesleyan University's privacy-tech-lab</a>.
      </br>
        Feel free to take a look at our other projects on the
      <a href="https://github.com/privacy-tech-lab">
        privacy-tech-lab GitHub</a>.
    </p>

    <p class="uk-width-3-4 question">
      <b>Where can I reach you?</b>
    </p>
    <p class="uk-width-3-4 answer">
      Feel free to shoot us an email @
      <a href="mailto:sebastian@privacytechlab.org">
        sebastian@privacytechlab.org</a> with any feedback or questions!
    </p>

    <p class="uk-width-3-4 question">
      <b>Do you have an FAQ or a place to report bugs?</b>
    </p>
    <p class="uk-width-3-4 answer">
      If you have questions about OptMeowt's functionality or 
      believe you may have found a bug, please check out our 
<a href="https://github.com/privacy-tech-lab/gpc-optmeowt/wiki/FAQ-%5C-Known-quirks">FAQ \ Known quirks</a> 
      page on our GitHub 
<a href="https://github.com/privacy-tech-lab/gpc-optmeowt/wiki">Wiki</a> 
      to see if we have already addressed the issue. 
      If you cannot find what you are looking for, please feel free 
      to open an issue and we will address it as soon as we can! 
    </p>

    <p class="uk-width-3-4 answer">
      Note: OptMeowt is a work in progress ...
    </p>
  </div>
</template>


================================================
FILE: src/options/views/about-view/about-view.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
about-view.js
================================================================================
about-view.js loads about-view.html when clicked on the options page
*/

import { renderParse, fetchParse } from "../../components/util.js";

/**
 * @typedef headings
 * @property {string} headings.title - Title of the given page
 * @property {string} headings.subtitle - Subtitle of the given page
 */
const headings = {
  title: "About",
  subtitle: "Learn more about OptMeowt",
};

/**
 * Renders the `About` view in the options page
 * @param {string} scaffoldTemplate - stringified HTML template
 */
export async function aboutView(scaffoldTemplate) {
  const body = renderParse(scaffoldTemplate, headings, "scaffold-component");
  let content = await fetchParse(
    "./views/about-view/about-view.html",
    "about-view"
  );

  document.getElementById("content").innerHTML = body.innerHTML;
  document.getElementById("scaffold-component-body").innerHTML =
    content.innerHTML;
}


================================================
FILE: src/options/views/domainlist-view/domainlist-view.html
================================================
<!--
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
-->


<!--
domainlist-view.html
================================================================================
domainlist-view.html contains the 'domainlist' view template to be loaded into the
options page when clicked
-->


<!--
    This is the body content inflated into scaffold-component.html when
    the `domainlist view` is called by a user from within the options page.
-->
<template id="domainlist-view">
  <div uk-grid>
    <div class="uk-width-3-4" style="margin-top: 0px;">
      
      <!-- Navbar with "Delete All" button -->
      <div class="domainlist-navbar" id="domainlist-navbar" style="display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 5px;">
        <div class="uk-text-lead uk-text-bold text-color-darker">
          Domains
        </div>
        <button
          id="delete-all-domains"
          class="uk-badge button"
          type="button"
          style="
            padding: 5px 10px;
            background-color: white;
            border: 1px solid #e06d62;
            color: #e06d62;
            position: absolute; /* Remove from the normal flow */
            right: 0; /* Place it all the way to the right */
            margin-right: 119px; /* Fine-tune with additional spacing */
          "
        >
          Delete All
        </button>
        </div>
        <br>
      </div>

      <!-- Domainlist -->
      <ul
        class="uk-list uk-list-divider uk-width-1-1"
        style="margin-top: 0px; margin-bottom: 0px;"
        id="domainlist-main"
      >
      <li>
        <div uk-grid class="uk-grid-small uk-width-1-1" style="font-size: medium;">
          <div class="domain uk-width-expand" >
            Loading...
          </div>
          <div style="
            margin-right: auto;
            margin-left: auto;
            margin-top: auto;
            margin-bottom: auto;
            "
          >
        </div>
      </li>
      </ul>
      
      <!-- Custom Confirmation Modal -->
      <div id="confirm-modal" class="hidden">
        <div id="modal-content">
          <p>Are you sure you want to delete all domains?</p>
          <button id="confirm-yes">Yes</button>
          <button id="confirm-no">No</button>
        </div>
      </div>

      <style>
        #confirm-modal {
          position: fixed;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background-color: rgba(0, 0, 0, 0.5);
          display: flex;
          justify-content: center;
          align-items: center;
        }
        #modal-content {
          background-color: white;
          padding: 20px;
          border-radius: 8px;
          text-align: center;
        }

        #modal-content p {
          color: #333; /* Darker text color */
        }
        
        #confirm-modal.hidden {
          display: none;
        }
      </style>

      <!-- Custom Alert Modal -->
      <div id="alert-modal" class="hidden">
        <div id="alert-modal-content">
          <p></p>
          <button id="alert-ok">OK</button>
        </div>
      </div>
      <style>
      #alert-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
      }
      #alert-modal-content {
        background-color: white;
        padding: 20px;
        border-radius: 8px;
        text-align: center;
      }
      
      #alert-modal-content p {
        color: #333; /* Darker text color */
      }

      #alert-modal.hidden {
        display: none;
      }
      #alert-ok {
        background-color: #e06d62;
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 5px;
        cursor: pointer;
      }
      #alert-ok:hover {
        background-color: #d05c52;
        }
        </style>

        </div>
      </div>
    </template>


================================================
FILE: src/options/views/domainlist-view/domainlist-view.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
domainlist-view.js
================================================================================
domainlist-view.js loads domainlist-view.html when clicked on the options page
*/

import { storage, stores } from "../../../background/storage.js";
import { renderParse, fetchParse } from "../../components/util.js";

import {
  addDomainToDomainlistAndRules,
  removeDomainFromDomainlistAndRules,
  updateRemovalScript,
  deleteCS
} from "../../../common/editDomainlist.js";
import { reloadDynamicRules } from "../../../common/editRules.js";

/******************************************************************************/
/***************************** Toggle Functions *******************************/
/******************************************************************************/

/**
 * Generates the HTML that will build the domainlist switch for a given
 * domain in the domainlist
 * @param {string} domain - Any given domain
 * @param {(number|null)} id - Dynamic rule ID if domainlisted as "excluded"
 * @return {string} - The stringified checkbox HTML compontent
 */
export function buildToggle(domain, id) {
  let toggle;
  if (!id) {
    toggle = `<input type="checkbox" id="${domain}" checked />`;
  } else {
    toggle = `<input type="checkbox" id="${domain}" />`;
  }
  return toggle;
}

/**
 * Creates an event listener that toggles a given domain's stored value in
 * the domainlist if a user clicks on the object with the given element ID
 * @param {string} elementId - HTML element to be linked to the listener
 * @param {string} domain - domain to be changed in domainlist
 */
export async function toggleListener(elementId, domain) {
  document.getElementById(elementId).addEventListener("click", async () => {
    const domainId = await storage.get(stores.domainlist, domain);
    if (domainId == null) {
      await addDomainToDomainlistAndRules(domain);
    } else {
      await removeDomainFromDomainlistAndRules(domain);
    }

    chrome.runtime.sendMessage({
      msg: "FORCE_RELOAD",
    });
  });
}

function showConfirmModal(message, callback) {
  const modal = document.getElementById("confirm-modal");
  const yesButton = document.getElementById("confirm-yes");
  const noButton = document.getElementById("confirm-no");

  // Set the message in the modal
  modal.querySelector("p").textContent = message;

  // Show the modal
  modal.classList.remove("hidden");

  // Handle "Yes" button click
  yesButton.onclick = () => {
      callback(true);  // Pass true to the callback if "Yes" was clicked
      modal.classList.add("hidden");  // Hide the modal
  };

  // Handle "No" button click
  noButton.onclick = () => {
      callback(false);  // Pass false to the callback if "No" was clicked
      modal.classList.add("hidden");  // Hide the modal
  };
}

function showAlert(message, callback) {
  const modal = document.getElementById("alert-modal");
  const okButton = document.getElementById("alert-ok");

  // Set the message in the modal
  modal.querySelector("p").textContent = message;

  // Show the modal
  modal.classList.remove("hidden");

  // Handle "OK" button click
  okButton.onclick = () => {
      callback();  // Call the callback after the alert is dismissed
      modal.classList.add("hidden");  // Hide the modal
  };
}

/**
 * Creates the specific Domain List toggles as well as the perm delete
 * buttons for each domain
 */
async function createToggleListeners() {
  const domainlistKeys = await storage.getAllKeys(stores.domainlist);
  const domainlistValues = await storage.getAll(stores.domainlist);
  let domain;
  let domainValue;
  for (let index in domainlistKeys) {
    domain = domainlistKeys[index];
    domainValue = domainlistValues[index];
    // MAKE SURE THE ID MATCHES EXACTLY
    toggleListener(domain, domain);
    deleteButtonListener(domain);
  }
}

/**
 * Delete buttons for each domain
 * @param {string} domain
 */
 function deleteButtonListener(domain) {
  document
    .getElementById(`delete ${domain}`)
    .addEventListener("click", async () => {
      const deletePrompt = `Are you sure you would like to delete this domain from the Domain List?`;
      const successPrompt = `Successfully deleted ${domain} from the Domain List.`;

      showConfirmModal(deletePrompt, async (confirmed) => {
        if (confirmed) {
          // Proceed with deletion if user confirms
          await storage.delete(stores.domainlist, domain);

          reloadDynamicRules();
          updateRemovalScript();
          deleteCS();

          // Replacing alert() with custom showAlert()
          showAlert(successPrompt, () => {
            document.getElementById(`li ${domain}`).remove();
          });
        }
      });
    });
}
/******************************************************************************/

/**
 * @typedef headings
 * @property {string} headings.title - Title of the given page
 * @property {string} headings.subtitle - Subtitle of the given page
 */
const headings = {
  title: "Domain List",
  subtitle:
    "Toggle which domains you would like to receive Global Privacy Control signals in Protection Mode",
};

/**
 * Creates the event listeners for the `domainlist` page buttons and options
 */
async function eventListeners() {
  await createToggleListeners();

  document.getElementById("delete-all-domains").addEventListener("click", async () => {
    const deletePrompt = `Are you sure you would like to delete all domains from the Domain List?`;
    const successPrompt = `Successfully deleted all domains from the Domain List.`;

    showConfirmModal(deletePrompt, async (confirmed) => {
        if (confirmed) {
            // If user clicks "Yes", proceed with deletion
            const domainlistKeys = await storage.getAllKeys(stores.domainlist);
            
            for (let domain of domainlistKeys) {
                await storage.delete(stores.domainlist, domain);
            }

            reloadDynamicRules();
            updateRemovalScript();
            deleteCS();

            // Show success message using the custom alert modal
            showAlert(successPrompt, () => {
                document.getElementById("domainlist-main").innerHTML = "";  // Clears the list visually
            });
        } else {
            // No action taken if user clicks "No"
        }
    });
});

  window.onscroll = function () {
    stickyNavbar();
  };
  var nb = document.getElementById("domainlist-navbar");
  var sticky = nb.offsetTop;

  /**
   * Sticky navbar
   */
  function stickyNavbar() {
    if (window.pageYOffset >= sticky) {
      nb.classList.add("sticky");
    } else {
      nb.classList.remove("sticky");
    }
  }
}

/**
 * Builds the list of domains in the domainlist, and their respective
 * options, to be displayed
 */
async function buildList() {
  let items = "";
  let domain;
  let domainValue;
  const domainlistKeys = await storage.getAllKeys(stores.domainlist);
  const domainlistValues = await storage.getAll(stores.domainlist);
  for (let index in domainlistKeys) {
    domain = domainlistKeys[index];
    domainValue = domainlistValues[index];
    items +=
      `
    <li id="li ${domain}">
      <div uk-grid class="uk-grid-small uk-width-1-1" style="font-size: medium;">
        <div>
          <label class="switch">
          ` +
      buildToggle(domain, domainValue) +
      `
            <span></span>
          </label>
        </div>
        <div class="domain uk-width-expand">
          ${domain}
        </div>
        <div style="
          margin-right: 5px;
          margin-left: 5px;
          margin-top: auto;
          margin-bottom: auto;
          "
        >
          <label class="switch" >
            <span></span>
          </label>
        </div>
          <button
            id="delete ${domain}"
            class="uk-badge button"
            type="button"
            style="
              margin-right: 5px;
              margin-left: 5px;
              margin-top: auto;
              margin-bottom: auto;
              padding-right: 5px;
              padding-left: 5px;
              background-color: white;
              border: 1px solid #e06d62;
              color: #e06d62;
            "
          >
            Delete
          </button>
      </div>
    </li>
          `;
  }
  document.getElementById("domainlist-main").innerHTML = items;
}

/**
 * Renders the `domain list` view in the options page
 * @param {string} scaffoldTemplate - stringified HTML template
 */
export async function domainlistView(scaffoldTemplate) {
  const body = renderParse(scaffoldTemplate, headings, "scaffold-component");
  let content = await fetchParse(
    "./views/domainlist-view/domainlist-view.html",
    "domainlist-view"
  );

  document.getElementById("content").innerHTML = body.innerHTML;
  document.getElementById("scaffold-component-body").innerHTML =
    content.innerHTML;

  await buildList();
  eventListeners();
}


================================================
FILE: src/options/views/main-view/main-view.html
================================================
<!--
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
-->

<!--
main-view.html
================================================================================
main-view.html defines the main structure of the about page and handles
navigation
-->

<!--
    This page defines the parts of the options page that are not the main
    content, specifically the persistent navigation bar that connects to
    every other page.
-->
<template id="main-view">
  <div uk-height-viewport class="uk-padding-large uk-overflow-hidden">
    <div class="uk-flex uk-flex-center@l">
      <div
        class="uk-grid-collapse uk-width-expand"
        uk-grid
        style="max-width: 1366px; min-width: 320px"
      >
        <!-- Width spacer for sidebar -->
        <div class="uk-width-small"></div>
        <!-- Sidebar -->
        <div class="uk-width-small uk-position-fixed">
          <!-- Logo -->
          <div class="first-column">
            <img
              src="../../../assets/cat-w-text/optmeow-logo-circle.png"
              alt="Logo"
              style="width: 125px; height: 125px"
            />
          </div>
          <!-- Navigation bar -->
          <div
            class="first-column uk-flex-inline uk-width-expand"
            style="
              border-right: 1px solid #e5e5e5;
              padding-bottom: 128px;
              padding-top: 32px;
              padding-left: 10px;
            "
          >
            <ul class="uk-nav uk-nav-default">
              <div class="uk-transition-toggle uk-h4" tabindex="0">
                <li
                  class="uk-transition-scale-up navbar-item"
                  id="main-view-settings"
                >
                  Settings
                </li>
              </div>
              <div class="uk-transition-toggle uk-h4" tabindex="0">
                <li
                  class="uk-transition-scale-up navbar-item"
                  id="main-view-domainlist"
                >
                  Domain List
                </li>
              </div>
              <div class="uk-transition-toggle uk-h4" tabindex="0">
                <li
                  class="uk-transition-scale-up navbar-item"
                  id="main-view-about"
                >
                  About
                </li>
              </div>
            </ul>
          </div>
        </div>
        <!-- Scrollable Content -->
        <div class="uk-width-expand" id="content">
          <!-- Content will be inflated here-->
        </div>
      </div>
    </div>
  </div>
</template>


================================================
FILE: src/options/views/main-view/main-view.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
main-view.js
================================================================================
main-view.js handles the navigation between different parts of the options page
and loads them when called through the navigation bar
*/


import { fetchTemplate, parseTemplate } from "../../components/util.js";
import { settingsView } from "../settings-view/settings-view.js";
import { domainlistView } from "../domainlist-view/domainlist-view.js";
import { aboutView } from "../about-view/about-view.js";
import { storage, stores } from "../../../background/storage.js";
import Darkmode from "../../../theme/darkmode.js";

/**
 * Opens the `Settings` page
 * @param {string} bodyTemplate - stringified HTML template
 */
async function displaySettings(bodyTemplate) {
  settingsView(bodyTemplate);
  document.querySelector(".navbar-item.active").classList.remove("active");
  document.querySelector("#main-view-settings").classList.add("active");
}

/**
 * Opens the `Domainlist` page
 * @param {string} bodyTemplate - stringified HTML template
 */
function displayDomainlist(bodyTemplate) {
  domainlistView(bodyTemplate);
  document.querySelector(".navbar-item.active").classList.remove("active");
  document.querySelector("#main-view-domainlist").classList.add("active");
}

/**
 * Opens the `Display` page
 * @param {string} bodyTemplate - stringified HTML template
 */
function displayAbout(bodyTemplate) {
  aboutView(bodyTemplate);
  document.querySelector(".navbar-item.active").classList.remove("active");
  document.querySelector("#main-view-about").classList.add("active");
}

/**
 * Prepares the `Main` page elements and intializes the default `Settings` page
 */
export async function mainView() {
  let docTemplate = await fetchTemplate("./views/main-view/main-view.html");
  const bodyTemplate = await fetchTemplate(
    "./components/scaffold-component.html"
  );
  document.body.innerHTML =
    parseTemplate(docTemplate).getElementById("main-view").innerHTML;

  let domainlistPressed = await storage.get(
    stores.settings,
    "DOMAINLIST_PRESSED"
  );

  if (!domainlistPressed) {
    settingsView(bodyTemplate); // First page
    document.querySelector("#main-view-settings").classList.add("active");
  } else if (domainlistPressed) {
    domainlistView(bodyTemplate); // First page
    await storage.set(stores.settings, false, "DOMAINLIST_PRESSED");
    document.querySelector("#main-view-domainlist").classList.add("active");}

  document
    .getElementById("main-view-settings")
    .addEventListener("click", () => displaySettings(bodyTemplate));
  document
    .getElementById("main-view-domainlist")
    .addEventListener("click", () => displayDomainlist(bodyTemplate));
  document
    .getElementById("main-view-about")
    .addEventListener("click", () => displayAbout(bodyTemplate));

  // DARK MODE
  const darkmode = new Darkmode();

  //Listener: Listens for a message sent by popup.js
  chrome.runtime.onMessage.addListener(function (
    message,
    sender,
    sendResponse
  ) {
    if (message.msg === "DARKSWITCH_PRESSED") {
      darkmode.toggle();
    }
    if (message.msg === "SHOW_TUTORIAL") {
      displaySettings(bodyTemplate);
    }
  });
}


================================================
FILE: src/options/views/settings-view/settings-view.html
================================================
<!--
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
-->


<!--
settings-view.html
================================================================================
settings-view.html contains the 'settings' view template to be loaded into the
options page when clicked
-->


<!--
    This is the body content inflated into scaffold-component.html when
    the `settings view` is called by a user from within the options page.
-->
<template id="settings-view">
  <div id="welcome-modal" uk-modal>
    <div class="uk-modal-dialog">
      <button class="uk-modal-close-default" type="button" uk-close></button>
      <div class="uk-modal-header uk-flex uk-flex-column uk-flex-middle">
        <img src="../../../assets/face-icons/icon64-face-circle.png" alt="" style="margin: 0px;">
        <h2 class="uk-align-center text-color-darker">Welcome to OptMeowt!</h2>
      </div>
      <div class="uk-modal-body" style="font-size: 15px; text-align: center;">
        OptMeowt has been successfully installed on your browser! Would you like a quick walkthrough of the options
        page?
      </div>
      <div class="uk-modal-footer">
        <button id="modal-button-1" class="text-color uk-button uk-button-default uk-align-right"
          style="margin: 0px 10px;">NOT NOW</button>
        <button id="modal-button-2" class="text-color uk-button uk-button-default uk-align-right"
          style="margin: 0px 10px;">OK</button>
      </div>
    </div>
  </div>

  <div id="permission-modal" uk-modal>
    <div class="uk-modal-dialog">
      <button class="uk-modal-close-default" type="button" uk-close></button>
      <div class="uk-modal-header uk-flex uk-flex-column uk-flex-middle">
        <img src="../../../assets/face-icons/icon64-face-circle.png" alt="" style="margin: 0px;">
        <h2 class="uk-align-center text-color-darker">Welcome to OptMeowt!</h2>
      </div>
      <div class="uk-modal-body" style="font-size: 15px; text-align: center;">
        OptMeowt requires host permissions to be enabled to function correctly, please enable these permissions using
        the button below. Note that OptMeowt does not collect your data!
      </div>
      <div class="uk-modal-footer">
        <button id="modal-button-4" class="text-color uk-button uk-button-default"
          style="display: block; margin: 0 auto;">ENABLE</button>
      </div>
    </div>
  </div>

  <div>
    <label>
      <div uk-grid class="uk-grid-column-small" style="margin-left: 0px;">
        <div class="uk-container" style="margin: auto;">
          <input class="uk-radio" type="radio" name="radio" id="settings-view-radio0" />
        </div>
        <div uk-grid class="uk-grid-row-collapse uk-width-expand">
          <div class="uk-first-column uk-width-1-1 uk-text-bold settings-popup1" style="font-size: large;"
            id="settings-view-radio0-text">
            Enable
          </div>
          <div class="uk-first-column uk-width-1-1" style="font-size: small;">
            Sends 'Global Privacy Control' signals to every visited domain
          </div>
        </div>
      </div>
    </label>
    <br />
    <label>
      <div uk-grid class="uk-grid-column-small" style="margin-left: 0px;">
        <div class="uk-container" style="margin: auto;">
          <input class="uk-radio" type="radio" name="radio" id="settings-view-radio2" />
        </div>
        <div uk-grid class="uk-grid-row-collapse uk-width-expand">
          <div class="uk-first-column uk-width-1-1 uk-text-bold tutorial-tooltip1" style="font-size: large;">
            Domain List
          </div>
          <div class="uk-first-column uk-width-1-1" style="font-size: small;">
            Sends 'Global Privacy Control' signals according to the custom Domain List
          </div>
        </div>
      </div>
    </label>
    <br />
    <label>
      <div uk-grid class="uk-grid-column-small" style="margin-left: 0px;">
        <div class="uk-container" style="margin: auto;">
          <input class="uk-radio" type="radio" name="radio" id="settings-view-radio1" />
        </div>
        <div uk-grid class="uk-grid-row-collapse uk-width-expand">
          <div class="uk-first-column uk-width-1-1 uk-text-bold" style="font-size: large;"
            id="settings-view-radio1-text">
            Disable
          </div>
          <div class="uk-first-column uk-width-1-1" style="font-size: small;">
            Does not send any 'Global Privacy Control' signals
          </div>
        </div>
      </div>
    </label>
  </div>
  </div>
  <div class="uk-text-small uk-text-muted" style="font-size: x-small; margin-top: 10px;">
    ** Please note that the privacy preferences you configure in OptMeowt may be influenced by global browser settings,
    like enabling GPC browser-wide.
  </div>
  <hr style="margin-top: 5px; margin-bottom: 5px;">
  <div style="font-weight: bold; font-size: medium; padding-bottom: 10px;">
    Advanced Options
  </div>
  <div class="uk-margin-small">
    <label>
      <div uk-grid class="uk-grid-column-small" style="margin-left: 0px;">
        <div class="uk-container" style="margin: auto;">
          <input class="uk-checkbox" type="checkbox" id="wellknown-check-toggle" />
        </div>
        <div uk-grid class="uk-grid-row-collapse uk-width-expand">
          <div class="uk-first-column uk-width-1-1 uk-text-bold" style="font-size: medium;">
            Check for /.well-known/gpc.json
          </div>
          <div class="uk-first-column uk-width-1-1" style="font-size: small;">
            Disable to stop the request and hide this info in the popup
          </div>
        </div>
      </div>
    </label>
  </div>
  <div class="uk-margin-small">
    <label>
      <div uk-grid class="uk-grid-column-small" style="margin-left: 0px;">
        <div uk-grid class="uk-grid-row-collapse uk-width-expand">
          <div class="uk-first-column uk-width-1-1 uk-text-bold" style="font-size: medium;">
            GPC Compliance State
          </div>
          <div class="uk-first-column uk-width-1-1" style="font-size: small;">
            Select your state to see compliance data, or choose "None" to hide
          </div>
          <div class="uk-first-column uk-width-1-1" style="margin-top: 6px;">
            <select id="state-select" class="uk-select" style="width: 200px; font-size: small;">
              <option value="none">None (hidden)</option>
              <option value="CA">California</option>
              <option value="CO">Colorado</option>
              <option value="CT">Connecticut</option>
              <option value="NJ">New Jersey</option>
            </select>
          </div>
        </div>
      </div>
    </label>
  </div>
  <div uk-grid>
    <div>
      <button id="download-button" class="importexport-button">
        Export Domain List
        </a>
    </div>
    <div>
      <button id="upload-button" class="importexport-button tutorial-tooltip2">
        Import Domain List from File
      </button>
      <input hidden type="file" accept=".json" id="upload-domainlist">
      </input>
    </div>
  </div>

  <br>

  <div id="thank-you-modal" uk-modal>
    <div class="uk-modal-dialog">
      <button class="uk-modal-close-default" type="button" uk-close></button>
      <div class="uk-modal-header uk-flex uk-flex-column uk-flex-middle">
        <img src="../../../assets/face-icons/optmeow-face-circle-green-ring-128.png" alt="">
      </div>
      <div class="uk-modal-body" style="font-size: 15px; text-align: center;">
        <h2 class="text-color-darker">Enjoy Using OptMeowt!</h2>
      </div>
      <div class="uk-modal-footer">
        <button id="modal-button-3" class="text-color uk-button uk-button-default uk-align-center">Learn More About
          Us</button>
      </div>
    </div>
  </div>


</template>

================================================
FILE: src/options/views/settings-view/settings-view.js
================================================
/*
Licensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md
privacy-tech-lab, https://privacytechlab.org/
*/

/*
settings-view.js
================================================================================
settings-view.js loads settings-view.html when clicked on the options page
*/

import { renderParse, fetchParse } from "../../components/util.js";
import {
  handleDownload,
  startUpload,
  handleUpload,
  stores,
  storage,
} from "../../../background/storage.js";

// Used in tutorial
import UIkit from "../../../../node_modules/uikit/dist/js/uikit.js";
import tippy from "../../../../node_modules/tippy.js/dist/tippy-bundle.umd.js";

import "../../../../node_modules/file-saver/src/FileSaver.js";
import Darkmode from "darkmode-js"; // check darkmode
import {
  addDynamicRule,
  deleteAllDynamicRules,
  reloadDynamicRules,
} from "../../../common/editRules.js";
import { isWellknownCheckEnabled } from "../../../common/settings.js";
import { updateRemovalScript } from "../../../common/editDomainlist.js";



/**
 * @typedef headings
 * @property {string} headings.title - Title of the given page
 * @property {string} headings.subtitle - Subtitle of the given page
 */
const headings = {
  title: "Settings",
  subtitle: "Adjust extension settings",
};


/**
 * Creates the event listeners for the `Settings` page buttons and options
 */
function eventListeners() {
  document
    .getElementById("settings-view-radio0")
    .addEventListener("click", () => {
      chrome.runtime.sendMessage({
        msg: "TURN_ON_OFF",
        data: { isEnabled: true },
      });
      chrome.runtime.sendMessage({
        msg: "CHANGE_IS_DOMAINLISTED",
        data: { isDomainlisted: false },
      });
      chrome.scripting.updateContentScripts([
        {
          id: "1",
          matches: ["<all_urls>"],
          excludeMatches: [],
          js: ["content-scripts/registration/gpc-dom.js"],
          runAt: "document_start",
        },
      ]);
      deleteAllDynamicRules();
    });
  document
    .getElementById("settings-view-radio1")
    .addEventListener("click", () => {
      chrome.runtime.sendMessage({
        msg: "TURN_ON_OFF",
        data: { isEnabled: false },
      });
      chrome.runtime.sendMessage({
        msg: "CHANGE_IS_DOMAINLISTED",
        data: { isDomainlisted: false },
      });
      chrome.scripting.updateContentScripts([
        {
          id: "1",
          matches: ["https://example.com/foo/bar.html"],
          excludeMatches: [],
          js: ["content-scripts/registration/gpc-dom.js"],
          runAt: "document_start",
        },
      ]);
      addDynamicRule(4999, "*");
    });
  document
    .getElementById("settings-view-radio2")
    .addEventListener("click", () => {
      chrome.runtime.sendMessage({
        msg: "TURN_ON_OFF",
        data: { isEnabled: true },
      });
      chrome.runtime.sendMessage({
        msg: "CHANGE_IS_DOMAINLISTED",
        data: { isDomainlisted: true },
      });
      updateRemovalScript();
      reloadDynamicRules();
    });
  document
    .getElementById("download-button")
    .addEventListener("click", handleDownload);
  document
    .getElementById("wellknown-check-toggle")
    .addEventListener("change", async (event) => {
      const enabled = event.target.checked;
      await storage.set(
        stores.settings,
        enabled,
        "WELLKNOWN_CHECK_ENABLED"
      );
      await chrome.storage.local.set({ WELLKNOWN_CHECK_ENABLED: enabled });
      chrome.runtime.sendMessage({
        msg: "TOGGLE_WELLKNOWN_CHECK",
        data: { enabled },
      });
    });
  document
    .getElementById("state-select")
    .addEventListener("change", async (event) => {
      const stateCode = event.target.value;
      await storage.set(
        stores.settings,
        stateCode,
        "USER_STATE"
      );
      // Clear cached compliance data when state changes
      await storage.clear(stores.complianceData);

      // Set loading flag immediately
      await storage.set(stores.settings, true, "COMPLIANCE_LOADING");

      // Notify background script to start fetching new data immediately
      chrome.runtime.sendMessage({ msg: "USER_STATE_CHANGE" });
    });
  document.getElementById("upload-button").addEventListener("click", () => {
    const verify = confirm(
      `This option will load a list of domains from a file, clearing all domains currently in the list.\\n Do you wish to continue?`
    );
    if (verify) {
      startUpload();
    }
  });
  document
    .getElementById("upload-domainlist")
    .addEventListener("change", handleUpload, false);

  chrome.runtime.onMessage.addListener(async function (message, _, __) {
    if (message.msg === "SHOW_TUTORIAL") {
      if ("$BROWSER" == "chrome") {
        chrome.tabs.reload();
      } else {
        await storage.set(stores.settings, true, "TUTORIAL_SHOWN");
        walkthrough();
      }
    }
  });
}


/******************************************************************************/

/*
 * Gives user a walkthrough of install page on first install
 */


function walkthrough() {
  let modal = UIkit.modal("#welcome-modal");
  modal.show();

  document.getElementById("modal-button-1").onclick = function () {
    modal.hide();
  };

  document.getElementById("modal-button-2").onclick = function () {
    modal.hide();
    tippy(".tutorial-tooltip1", {
      content:
        "<p>Set which sites should receive a Global Privacy Control signal<p>  <button class='uk-button uk-button-default'>Next</button>",
      allowHTML: true,
      trigger: "manual",
      placement: "right",
      offset: [0, -600],
      duration: 1000,
      theme: "custom-1",
      onHide(instance) {
        trigger2();
      },
    });
    let tooltip =
      document.getElementsByClassName("tutorial-tooltip1")[0]._tippy;
    tooltip.show();
  };

  function trigger2() {
    tippy(".tutorial-tooltip2", {
      content:
        "<p>Import and export your customized list of sites that should receive a signal<p>  <button class='uk-button uk-button-default'>Next</button>",
      allowHTML: true,
      trigger: "manual",
      duration: 1000,
      theme: "custom-1",
      placement: "right",
      offset: [0, 60],
      onHide() {
        trigger4();
      },
    });
    let tooltip =
      document.getElementsByClassName("tutorial-tooltip2")[0]._tippy;
    tooltip.show();
  }

  function trigger4() {
    let modal = UIkit.modal("#thank-you-modal");
    modal.show();
    document.getElementById("modal-button-3").onclick = () => {
      chrome.tabs.create(
        { url: "https://privacytechlab.org/" },
        function (tab) { }
      );
    };
  }
}

/*
 * Request host permissions upon install
 */

async function requestPermissionsButton() {
  try {
    // Request permissions
    const response = await browser.permissions.request({
      origins: ["<all_urls>"] // Allows host permissions
    });

    // Check if permissions were granted or refused
    if (response) {
      console.log("Permissions were granted");
      storage.set(stores.settings, true, "REQUEST_PERMISSIONS_SHOWN");
    } else {
      console.log("Permissions were refused");
    }

    // Retrieve current permissions after the request
    const currentPermissions = await browser.permissions.getAll();
    console.log(`Current permissions:`, currentPermissions);
  } catch (error) {
    console.error('Error requesting permissions:', error);
  }
}

function requestPermissions() {
  let modal = UIkit.modal('#permission-modal');
  modal.show();
  document.getElementById("modal-button-4").onclick = () => {
    requestPermissionsButton();
    modal.hide();
  }
}

/******************************************************************************/

/**
 * Renders the `Settings` view in the options page
 * @param {string} scaffoldTemplate - stringified HTML template
 */
export async function settingsView(scaffoldTemplate) {
  const body = renderParse(scaffoldTemplate, headings, "scaffold-component");
  let content = await fetchParse(
    "./views/settings-view/settings-view.html",
    "settings-view"
  );

  document.getElementById("content").innerHTML = body.innerHTML;
  document.getElementById("scaffold-component-body").innerHTML =
    content.innerHTML;

  // Render correct extension mode radio button
  const isEnabled = await storage.get(stores.settings, "IS_ENABLED");
  const isDomainlisted = await storage.get(stores.settings, "IS_DOMAINLISTED");
  const wellknownCheckEnabled = await isWellknownCheckEnabled();

  if (isEnabled) {
    isDomainlisted
      ? (document.getElementById("settings-view-radio2").checked = true)
      : (document.getElementById("settings-view-radio0").checked = true);
  } else {
    document.getElementById("settings-view-radio1").checked = true;
  }

  document.getElementById("wellknown-check-toggle").checked =
    wellknownCheckEnabled;

  const userState = await storage.get(stores.settings, "U
Download .txt
gitextract_4uj713gw/

├── .github/
│   └── workflows/
│       └── node.js.yml
├── .gitignore
├── FUNDING.yml
├── LICENSE.md
├── README.md
├── README_ARCHITECTURE.md
├── package.json
├── src/
│   ├── assets/
│   │   └── icon.psd
│   ├── background/
│   │   ├── control.js
│   │   ├── protection/
│   │   │   ├── background.js
│   │   │   ├── listeners-chrome.js
│   │   │   ├── listeners-firefox.js
│   │   │   ├── protection-ff.js
│   │   │   └── protection.js
│   │   └── storage.js
│   ├── common/
│   │   ├── editDomainlist.js
│   │   ├── editRules.js
│   │   └── settings.js
│   ├── content-scripts/
│   │   ├── contentScript.js
│   │   ├── injection/
│   │   │   └── gpc-dom.js
│   │   └── registration/
│   │       └── gpc-dom.js
│   ├── data/
│   │   ├── complianceData.js
│   │   ├── defaultSettings.js
│   │   └── headers.js
│   ├── manifests/
│   │   ├── chrome/
│   │   │   ├── manifest-dev.json
│   │   │   └── manifest-dist.json
│   │   └── firefox/
│   │       ├── manifest-dev.json
│   │       └── manifest-dist.json
│   ├── options/
│   │   ├── components/
│   │   │   ├── scaffold-component.html
│   │   │   └── util.js
│   │   ├── dark-mode.css
│   │   ├── options.html
│   │   ├── options.js
│   │   ├── styles.css
│   │   └── views/
│   │       ├── about-view/
│   │       │   ├── about-view.html
│   │       │   └── about-view.js
│   │       ├── domainlist-view/
│   │       │   ├── domainlist-view.html
│   │       │   └── domainlist-view.js
│   │       ├── main-view/
│   │       │   ├── main-view.html
│   │       │   └── main-view.js
│   │       └── settings-view/
│   │           ├── settings-view.html
│   │           └── settings-view.js
│   ├── popup/
│   │   ├── popup.html
│   │   ├── popup.js
│   │   └── styles.css
│   ├── rules/
│   │   ├── gpc_exceptions_rules.json
│   │   └── universal_gpc_rules.json
│   └── theme/
│       └── darkmode.js
├── test/
│   └── background/
│       ├── cookieRemoval.test.js
│       └── gpc.test.js
├── ui-mockup/
│   ├── Mockup v1.0.xd
│   └── Popup designs/
│       └── Popup.xd
└── webpack.config.js
Download .txt
SYMBOL INDEX (176 symbols across 23 files)

FILE: src/background/control.js
  function enable (line 30) | async function enable() {
  function disable (line 35) | function disable() {

FILE: src/background/protection/background.js
  function init (line 40) | async function init() {
  function halt (line 44) | function halt() {

FILE: src/background/protection/listeners-chrome.js
  constant CHROME_REQUEST_SPEC (line 16) | const CHROME_REQUEST_SPEC = ["requestHeaders", "extraHeaders"];
  constant CHROME_RESPONSE_SPEC (line 17) | const CHROME_RESPONSE_SPEC = ["responseHeaders", "extraHeaders"];
  constant FILTER (line 19) | const FILTER = { urls: ["<all_urls>"] };
  function enableListeners (line 28) | function enableListeners(callbacks) {
  function disableListeners (line 56) | function disableListeners(callbacks) {

FILE: src/background/protection/listeners-firefox.js
  constant MOZ_REQUEST_SPEC (line 16) | const MOZ_REQUEST_SPEC = ["requestHeaders", "blocking"];
  constant MOZ_RESPONSE_SPEC (line 17) | const MOZ_RESPONSE_SPEC = ["responseHeaders", "blocking"];
  constant FILTER (line 20) | const FILTER = { urls: ["<all_urls>"] };
  function enableListeners (line 29) | function enableListeners(callbacks) {
  function disableListeners (line 57) | function disableListeners(callbacks) {

FILE: src/background/protection/protection-ff.js
  function reloadVars (line 36) | async function reloadVars() {
  function addHeaders (line 118) | function addHeaders(details) {
  function addDomSignal (line 131) | function addDomSignal(details) {
  function getCurrentParsedDomain (line 141) | function getCurrentParsedDomain() {
  function updateDomainlist (line 168) | async function updateDomainlist(details) {
  function updatePopupIcon (line 202) | function updatePopupIcon(details) {
  function logData (line 214) | function logData(details) {
  function pullToDomainlistCache (line 247) | async function pullToDomainlistCache() {
  function syncDomainlists (line 257) | async function syncDomainlists() {
  function sendPrivacySignal (line 293) | async function sendPrivacySignal(domain) {
  function handleSendMessageError (line 324) | function handleSendMessageError() {
  function dataToPopup (line 332) | function dataToPopup() {
  function onConnectHandler (line 372) | function onConnectHandler(port) {
  function onMessageHandlerSynchronous (line 387) | function onMessageHandlerSynchronous(message, sender, sendResponse) {
  function onMessageHandlerAsync (line 410) | async function onMessageHandlerAsync(message, sender, sendResponse) {
  function initMessagePassing (line 490) | function initMessagePassing() {
  function closeMessagePassing (line 496) | function closeMessagePassing() {
  function onActivatedProtectionMode (line 511) | function onActivatedProtectionMode(info) {
  function initSetup (line 516) | function initSetup() {
  function closeSetup (line 529) | function closeSetup() {
  function wipeLocalVars (line 536) | function wipeLocalVars() {
  function init (line 551) | function init() {
  function halt (line 559) | function halt() {

FILE: src/background/protection/protection.js
  constant DEFAULT_NO_DATA_STATUS (line 43) | const DEFAULT_NO_DATA_STATUS = {
  function reloadVars (line 49) | async function reloadVars() {
  function getComplianceData (line 130) | async function getComplianceData() {
  function handleComplianceCheck (line 190) | async function handleComplianceCheck(details) {
  function sendData (line 254) | async function sendData() {
  function getCurrentParsedDomain (line 281) | function getCurrentParsedDomain() {
  function updateDomainlist (line 312) | async function updateDomainlist(details) {
  function updatePopupIcon (line 355) | function updatePopupIcon(tabId) {
  function logData (line 362) | async function logData(details) {
  function pullToDomainlistCache (line 396) | async function pullToDomainlistCache() {
  function syncDomainlists (line 407) | async function syncDomainlists() {
  function sendPrivacySignal (line 443) | async function sendPrivacySignal(domain) {
  function handleSendMessageError (line 474) | function handleSendMessageError() {
  function dataToPopupHelper (line 480) | async function dataToPopupHelper() {
  function dataToPopup (line 496) | async function dataToPopup(wellknownData) {
  function dataToPopupRequests (line 514) | async function dataToPopupRequests() {
  function onConnectHandler (line 540) | function onConnectHandler(port) {
  function onMessageHandlerSynchronous (line 555) | function onMessageHandlerSynchronous(message, sender, sendResponse) {
  function onMessageHandlerAsync (line 578) | async function onMessageHandlerAsync(message, sender, sendResponse) {
  function initMessagePassing (line 710) | function initMessagePassing() {
  function closeMessagePassing (line 716) | function closeMessagePassing() {
  function onActivatedProtectionMode (line 731) | function onActivatedProtectionMode(info) {
  function initSetup (line 737) | function initSetup() {
  function closeSetup (line 751) | function closeSetup() {
  function wipeLocalVars (line 758) | function wipeLocalVars() {
  function init (line 773) | function init() {
  function halt (line 780) | function halt() {

FILE: src/background/storage.js
  method get (line 59) | async get(store, key) {
  method getAll (line 65) | async getAll(store) {
  method getAllKeys (line 68) | async getAllKeys(store) {
  method getStore (line 72) | async getStore(store) {
  method set (line 83) | async set(store, value, key) {
  method delete (line 89) | async delete(store, key) {
  method clear (line 95) | async clear(store) {
  function handleDownload (line 104) | async function handleDownload() {
  function startUpload (line 121) | async function startUpload() {
  function handleUpload (line 129) | async function handleUpload() {

FILE: src/common/editDomainlist.js
  function updateRemovalScript (line 31) | async function updateRemovalScript() {
  function createCS (line 58) | async function createCS(domain){
  function deleteCS (line 79) | async function deleteCS(domain){
  function deleteDomainlistAndDynamicRules (line 105) | async function deleteDomainlistAndDynamicRules() {
  function addDomainToDomainlistAndRules (line 110) | async function addDomainToDomainlistAndRules(domain) {
  function removeDomainFromDomainlistAndRules (line 118) | async function removeDomainFromDomainlistAndRules(domain) {
  function debug_domainlist_and_dynamicrules (line 131) | async function debug_domainlist_and_dynamicrules() {
  function print_rules_and_domainlist (line 163) | async function print_rules_and_domainlist() {

FILE: src/common/editRules.js
  function getFreshId (line 22) | async function getFreshId() {
  function deleteDynamicRule (line 52) | async function deleteDynamicRule(id) {
  function deleteAllDynamicRules (line 61) | async function deleteAllDynamicRules() {
  function addDynamicRule (line 75) | async function addDynamicRule(id, domain) {
  function reloadDynamicRules (line 121) | async function reloadDynamicRules() {

FILE: src/common/settings.js
  function isWellknownCheckEnabled (line 19) | async function isWellknownCheckEnabled() {
  function getUserState (line 29) | async function getUserState() {
  function isComplianceCheckEnabled (line 38) | async function isComplianceCheckEnabled() {

FILE: src/content-scripts/contentScript.js
  function injectScript (line 45) | function injectScript(script) {
  function isWellknownCheckEnabled (line 51) | async function isWellknownCheckEnabled() {
  function getWellknown (line 82) | async function getWellknown(url) {

FILE: src/content-scripts/injection/gpc-dom.js
  function setDomSignal (line 16) | function setDomSignal() {

FILE: src/content-scripts/registration/gpc-dom.js
  constant INJECTION_SCRIPT (line 24) | const INJECTION_SCRIPT = "content-scripts/injection/gpc-dom.js";
  function injectStaticScript (line 28) | function injectStaticScript() {

FILE: src/data/complianceData.js
  constant STATES_JSON_URL (line 33) | const STATES_JSON_URL =
  constant STATE_NAMES (line 37) | const STATE_NAMES = {
  constant CACHE_TTL_MS (line 47) | const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
  function toRawUrl (line 57) | function toRawUrl(blobUrl) {
  function fetchStatesConfig (line 73) | async function fetchStatesConfig() {
  constant SIGNAL_COLUMNS (line 82) | const SIGNAL_COLUMNS = [
  function isNullSignal (line 98) | function isNullSignal(val) {
  function parseCSVLine (line 111) | function parseCSVLine(line) {
  function parseClassification (line 149) | function parseClassification(raw) {
  function fetchDomainSet (line 166) | async function fetchDomainSet(url) {
  function fetchAllSitesData (line 213) | async function fetchAllSitesData(url) {
  function fetchComplianceData (line 280) | async function fetchComplianceData(stateCode) {
  function isCacheValid (line 360) | function isCacheValid(fetchedAt) {

FILE: src/options/components/util.js
  function fetchTemplate (line 20) | async function fetchTemplate(path) {
  function parseTemplate (line 31) | function parseTemplate(template) {
  function fetchParse (line 44) | async function fetchParse(path, id) {
  function renderParse (line 56) | function renderParse(template, data, id) {

FILE: src/options/views/about-view/about-view.js
  function aboutView (line 28) | async function aboutView(scaffoldTemplate) {

FILE: src/options/views/domainlist-view/domainlist-view.js
  function buildToggle (line 34) | function buildToggle(domain, id) {
  function toggleListener (line 50) | async function toggleListener(elementId, domain) {
  function showConfirmModal (line 65) | function showConfirmModal(message, callback) {
  function showAlert (line 89) | function showAlert(message, callback) {
  function createToggleListeners (line 110) | async function createToggleListeners() {
  function deleteButtonListener (line 128) | function deleteButtonListener(domain) {
  function eventListeners (line 168) | async function eventListeners() {
  function buildList (line 220) | async function buildList() {
  function domainlistView (line 284) | async function domainlistView(scaffoldTemplate) {

FILE: src/options/views/main-view/main-view.js
  function displaySettings (line 25) | async function displaySettings(bodyTemplate) {
  function displayDomainlist (line 35) | function displayDomainlist(bodyTemplate) {
  function displayAbout (line 45) | function displayAbout(bodyTemplate) {
  function mainView (line 54) | async function mainView() {

FILE: src/options/views/settings-view/settings-view.js
  function eventListeners (line 51) | function eventListeners() {
  function walkthrough (line 178) | function walkthrough() {
  function requestPermissionsButton (line 241) | async function requestPermissionsButton() {
  function requestPermissions (line 264) | function requestPermissions() {
  function settingsView (line 279) | async function settingsView(scaffoldTemplate) {

FILE: src/popup/popup.js
  function generateDarkmodeElement (line 55) | function generateDarkmodeElement() {
  function getCurrentParsedDomain (line 83) | function getCurrentParsedDomain() {
  function renderFirstPartyDomain (line 104) | function renderFirstPartyDomain(parsedDomain) {
  function renderExtensionIsEnabledDisabled (line 115) | function renderExtensionIsEnabledDisabled(isEnabled, isDomainlisted) {
  function turnonoff (line 141) | function turnonoff(isEnabled) {
  function listenerExtensionIsEnabledDisabledButton (line 159) | function listenerExtensionIsEnabledDisabledButton(
  function renderDomainCounter (line 206) | async function renderDomainCounter() {
  function renderFirstPartyDomainDNSToggle (line 219) | async function renderFirstPartyDomainDNSToggle() {
  function listenerFirstPartyDomainDNSToggleCallback (line 249) | async function listenerFirstPartyDomainDNSToggleCallback() {
  function listenerFirstPartyDomainDNSToggle (line 268) | function listenerFirstPartyDomainDNSToggle() {
  function removeFirstPartyDomainDNSToggle (line 274) | function removeFirstPartyDomainDNSToggle() {
  function renderDropdown1Toggle (line 284) | function renderDropdown1Toggle() {
  function renderDropdown2Toggle (line 304) | function renderDropdown2Toggle() {
  function listenerDropdown1ToggleCallback (line 324) | function listenerDropdown1ToggleCallback() {
  function listenerDropdown2ToggleCallback (line 344) | function listenerDropdown2ToggleCallback() {
  function listenerDropdown1Toggle (line 364) | function listenerDropdown1Toggle() {
  function listenerDropdown2Toggle (line 370) | function listenerDropdown2Toggle() {
  function removeListenerDropdown1Toggle (line 376) | function removeListenerDropdown1Toggle() {
  function removeListenerDropdown2Toggle (line 382) | function removeListenerDropdown2Toggle() {
  function showProtectionInfo (line 398) | async function showProtectionInfo() {
  function addThirdPartyDomainDNSToggleListener (line 561) | function addThirdPartyDomainDNSToggleListener(requestDomain) {
  function buildDomains (line 596) | async function buildDomains(requests) {
  function buildWellKnown (line 672) | async function buildWellKnown(requests) {
  function buildComplianceStatusLoading (line 749) | async function buildComplianceStatusLoading(stateCode) {
  constant CLASSIFICATION_STATUS_META (line 767) | const CLASSIFICATION_STATUS_META = {
  constant CLASSIFICATION_NONE_META (line 774) | const CLASSIFICATION_NONE_META  = { label: 'None',  cls: 'status-none' };
  constant CLASSIFICATION_MIXED_META (line 775) | const CLASSIFICATION_MIXED_META = { label: 'Mixed', cls: 'status-mixed' };
  function metaForStatus (line 777) | function metaForStatus(status) {
  function aggregateGppMeta (line 786) | function aggregateGppMeta(gpp) {
  function classificationRowHtml (line 795) | function classificationRowHtml(family, meta) {
  function buildClassificationHtml (line 804) | function buildClassificationHtml(classification) {
  function computeOverallVerdict (line 818) | function computeOverallVerdict(classification) {
  function overallBadgeHtml (line 833) | function overallBadgeHtml(classification) {
  function buildComplianceStatus (line 850) | async function buildComplianceStatus(status, stateCode, viewUrl) {
  function setToDomainlist (line 948) | function setToDomainlist(d, k) {
  function popUpWalkthrough (line 962) | function popUpWalkthrough() {
  function initPopUpWalkthrough (line 978) | async function initPopUpWalkthrough() {

FILE: src/theme/darkmode.js
  constant IS_BROWSER (line 19) | const IS_BROWSER = typeof window !== "undefined";
  class Darkmode (line 21) | class Darkmode {
    method constructor (line 22) | constructor(options) {
    method toggle (line 50) | toggle() {
    method isActivated (line 60) | isActivated() {

FILE: test/background/cookieRemoval.test.js
  function containsInDir (line 31) | function containsInDir(dirPath, needle) {

FILE: test/background/gpc.test.js
  function getElementByXpath (line 76) | function getElementByXpath(path) {
Condensed preview — 53 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (280K chars).
[
  {
    "path": ".github/workflows/node.js.yml",
    "chars": 819,
    "preview": "# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tes"
  },
  {
    "path": ".gitignore",
    "chars": 201,
    "preview": "# Local user files\n.DS_Store\n.idea\n.vscode\n\n# Node.js\nnode_modules\n\n# Distribution files\ndist\ndev\n\n# local env files\n.en"
  },
  {
    "path": "FUNDING.yml",
    "chars": 25,
    "preview": "github: privacy-tech-lab\n"
  },
  {
    "path": "LICENSE.md",
    "chars": 1073,
    "preview": "MIT License\n\nCopyright (c) 2021 privacy-tech-lab\n\nPermission is hereby granted, free of charge, to any person obtaining "
  },
  {
    "path": "README.md",
    "chars": 26122,
    "preview": "<p align=\"center\">\n  <a href=\"https://github.com/privacy-tech-lab/gpc-optmeowt/releases\"><img alt=\"GitHub release (lates"
  },
  {
    "path": "README_ARCHITECTURE.md",
    "chars": 6651,
    "preview": "# Architecture Overview\n\n```txt\nsrc\n├── assets       # Static images & files\n├── background      # Manages the backgroun"
  },
  {
    "path": "package.json",
    "chars": 2350,
    "preview": "{\n  \"name\": \"optmeowt\",\n  \"version\": \"6.1.0\",\n  \"description\": \"A privacy extension that allows users to exercise rights"
  },
  {
    "path": "src/background/control.js",
    "chars": 3513,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/background/protection/background.js",
    "chars": 1689,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/background/protection/listeners-chrome.js",
    "chars": 2349,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/background/protection/listeners-firefox.js",
    "chars": 2310,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/background/protection/protection-ff.js",
    "chars": 19047,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/background/protection/protection.js",
    "chars": 26509,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/background/storage.js",
    "chars": 5355,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/common/editDomainlist.js",
    "chars": 6055,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/common/editRules.js",
    "chars": 4043,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/common/settings.js",
    "chars": 1253,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/content-scripts/contentScript.js",
    "chars": 4927,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/content-scripts/injection/gpc-dom.js",
    "chars": 1040,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/content-scripts/registration/gpc-dom.js",
    "chars": 1429,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/data/complianceData.js",
    "chars": 12999,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/data/defaultSettings.js",
    "chars": 603,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/data/headers.js",
    "chars": 519,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/manifests/chrome/manifest-dev.json",
    "chars": 1541,
    "preview": "{\n  \"name\": \"OptMeowt\",\n  \"author\": \"privacy-tech-lab\",\n  \"version\": \"6.1.0\",\n  \"description\": \"OptMeowt allows Web user"
  },
  {
    "path": "src/manifests/chrome/manifest-dist.json",
    "chars": 1541,
    "preview": "{\n  \"name\": \"OptMeowt\",\n  \"author\": \"privacy-tech-lab\",\n  \"version\": \"6.1.0\",\n  \"description\": \"OptMeowt allows Web user"
  },
  {
    "path": "src/manifests/firefox/manifest-dev.json",
    "chars": 1582,
    "preview": "{\n  \"name\": \"OptMeowt\",\n  \"author\": \"privacy-tech-lab\",\n  \"version\": \"6.1.0\",\n  \"description\": \"OptMeowt allows Web user"
  },
  {
    "path": "src/manifests/firefox/manifest-dist.json",
    "chars": 1582,
    "preview": "{\n  \"name\": \"OptMeowt\",\n  \"author\": \"privacy-tech-lab\",\n  \"version\": \"6.1.0\",\n  \"description\": \"OptMeowt allows Web user"
  },
  {
    "path": "src/options/components/scaffold-component.html",
    "chars": 1221,
    "preview": "<!--\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privac"
  },
  {
    "path": "src/options/components/util.js",
    "chars": 1896,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/options/dark-mode.css",
    "chars": 4577,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/options/options.html",
    "chars": 731,
    "preview": "<!--\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privac"
  },
  {
    "path": "src/options/options.js",
    "chars": 1001,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/options/styles.css",
    "chars": 7293,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/options/views/about-view/about-view.html",
    "chars": 3336,
    "preview": "<!--\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privac"
  },
  {
    "path": "src/options/views/about-view/about-view.js",
    "chars": 1123,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/options/views/domainlist-view/domainlist-view.html",
    "chars": 4123,
    "preview": "<!--\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privac"
  },
  {
    "path": "src/options/views/domainlist-view/domainlist-view.js",
    "chars": 9067,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/options/views/main-view/main-view.html",
    "chars": 2641,
    "preview": "<!--\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privac"
  },
  {
    "path": "src/options/views/main-view/main-view.js",
    "chars": 3329,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/options/views/settings-view/settings-view.html",
    "chars": 7870,
    "preview": "<!--\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privac"
  },
  {
    "path": "src/options/views/settings-view/settings-view.js",
    "chars": 9431,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/popup/popup.html",
    "chars": 8523,
    "preview": "<!--\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privac"
  },
  {
    "path": "src/popup/popup.js",
    "chars": 37762,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/popup/styles.css",
    "chars": 7528,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "src/rules/gpc_exceptions_rules.json",
    "chars": 581,
    "preview": "[\n\t{\n\t\t\"id\": 2,\n\t\t\"priority\": 1,\n\t\t\"action\": {\n\t\t  \"type\": \"modifyHeaders\",\n\t\t  \"requestHeaders\": [\n        { \"header\": "
  },
  {
    "path": "src/rules/universal_gpc_rules.json",
    "chars": 628,
    "preview": "[\n  {\n    \"id\": 1,\n    \"priority\": 1,\n    \"action\": {\n      \"type\": \"modifyHeaders\",\n      \"requestHeaders\": [\n        {"
  },
  {
    "path": "src/theme/darkmode.js",
    "chars": 1865,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "test/background/cookieRemoval.test.js",
    "chars": 5762,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "test/background/gpc.test.js",
    "chars": 2630,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  },
  {
    "path": "webpack.config.js",
    "chars": 4392,
    "preview": "/*\nLicensed per https://github.com/privacy-tech-lab/gpc-optmeowt/blob/main/LICENSE.md\nprivacy-tech-lab, https://privacyt"
  }
]

// ... and 3 more files (download for full content)

About this extraction

This page contains the full source code of the privacy-tech-lab/gpc-optmeowt GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 53 files (258.2 KB), approximately 64.8k tokens, and a symbol index with 176 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!