From 5400e390b9cdc38c2ab18a8c8e6264586b56b9ee Mon Sep 17 00:00:00 2001
From: =Riky <=ra_mo116@hotmail.com>
Date: Mon, 14 Apr 2025 16:11:13 -0700
Subject: [PATCH 01/13] initial commit
---
README.md | 143 ++----------------------------------------------------
1 file changed, 3 insertions(+), 140 deletions(-)
diff --git a/README.md b/README.md
index 4d5ac098c..23060d91e 100755
--- a/README.md
+++ b/README.md
@@ -1,150 +1,13 @@
-
-
-# Chrome Extension (MV3) Boilerplate with React 18 and Webpack 5
-
-[](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
-[](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
-[](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
-
-## Announcements
-
-- Recently updated from **[React](https://reactjs.org)** ~~17~~ to **18**!
-- **_This boilerplate adopts [Manifest V3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/)!_**
- - For V2 users, please check out the [manifest-v2](https://github.com/lxieyang/chrome-extension-boilerplate-react/tree/manifest-v2) branch, or use version [3.x](https://www.npmjs.com/package/chrome-extension-boilerplate-react/v/3.3.0).
- - Check out the [Manifest V3 Migration Guide](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/).
-- Recently added [devtools](https://developer.chrome.com/docs/extensions/mv3/devtools/) Support! Thanks [GeekaholicLin](https://github.com/lxieyang/chrome-extension-boilerplate-react/issues/17)!
-- Recently updated from **[Webpack Dev Server](https://webpack.js.org/configuration/dev-server/)** ~~3.x~~ to **4.x** and **[Webpack](https://webpack.js.org/)** ~~4~~ to **5**!
-- Recently added [TypeScript](https://www.typescriptlang.org/) Support!
-
-## Features
-
-This is a basic Chrome Extensions boilerplate to help you write modular and modern Javascript code, load CSS easily and [automatic reload the browser on code changes](https://webpack.github.io/docs/webpack-dev-server.html#automatic-refresh).
-
-This boilerplate is updated with:
-
-- [Chrome Extension Manifest V3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/)
-- [React 18](https://reactjs.org)
-- [Webpack 5](https://webpack.js.org/)
-- [Webpack Dev Server 4](https://webpack.js.org/configuration/dev-server/)
-- [React Refresh](https://www.npmjs.com/package/react-refresh)
-- [react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin)
-- [eslint-config-react-app](https://www.npmjs.com/package/eslint-config-react-app)
-- [Prettier](https://prettier.io/)
-- [TypeScript](https://www.typescriptlang.org/)
-
-This boilerplate is heavily inspired by and adapted from [https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate), with additional support for React 18 features, Webpack 5, and Webpack Dev Server 4.
-
-Please open up an issue to nudge me to keep the npm packages up-to-date. FYI, it takes time to make different packages with different versions work together nicely.
-
## Installing and Running
### Procedures:
1. Check if your [Node.js](https://nodejs.org/) version is >= **18**.
2. Clone this repository.
-3. Change the package's `name`, `description`, and `repository` fields in `package.json`.
-4. Change the name of your extension on `src/manifest.json`.
-5. Run `npm install` to install the dependencies.
-6. Run `npm start`
-7. Load your extension on Chrome following:
+3. Run `npm install` to install the dependencies.
+4. Run `npm start`
+5. Load your extension on Chrome following:
1. Access `chrome://extensions/`
2. Check `Developer mode`
3. Click on `Load unpacked extension`
4. Select the `build` folder.
-8. Happy hacking.
-
-## Structure
-
-All your extension's code must be placed in the `src` folder.
-
-The boilerplate is already prepared to have a popup, an options page, a background page, and a new tab page (which replaces the new tab page of your browser). But feel free to customize these.
-
-## TypeScript
-
-This boilerplate now supports TypeScript! The `Options` Page is implemented using TypeScript. Please refer to `src/pages/Options/` for example usages.
-
-## Webpack auto-reload and HRM
-
-To make your workflow much more efficient this boilerplate uses the [webpack server](https://webpack.github.io/docs/webpack-dev-server.html) to development (started with `npm start`) with auto reload feature that reloads the browser automatically every time that you save some file in your editor.
-
-You can run the dev mode on other port if you want. Just specify the env var `port` like this:
-
-```
-$ PORT=6002 npm run start
-```
-
-## Content Scripts
-
-Although this boilerplate uses the webpack dev server, it's also prepared to write all your bundles files on the disk at every code change, so you can point, on your extension manifest, to your bundles that you want to use as [content scripts](https://developer.chrome.com/extensions/content_scripts), but you need to exclude these entry points from hot reloading [(why?)](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/issues/4#issuecomment-261788690). To do so you need to expose which entry points are content scripts on the `webpack.config.js` using the `chromeExtensionBoilerplate -> notHotReload` config. Look the example below.
-
-Let's say that you want use the `myContentScript` entry point as content script, so on your `webpack.config.js` you will configure the entry point and exclude it from hot reloading, like this:
-
-```js
-{
- …
- entry: {
- myContentScript: "./src/js/myContentScript.js"
- },
- chromeExtensionBoilerplate: {
- notHotReload: ["myContentScript"]
- }
- …
-}
-```
-
-and on your `src/manifest.json`:
-
-```json
-{
- "content_scripts": [
- {
- "matches": ["https://www.google.com/*"],
- "js": ["myContentScript.bundle.js"]
- }
- ]
-}
-```
-
-## Intelligent Code Completion
-
-Thanks to [@hudidit](https://github.com/lxieyang/chrome-extension-boilerplate-react/issues/4)'s kind suggestions, this boilerplate supports chrome-specific intelligent code completion using [@types/chrome](https://www.npmjs.com/package/@types/chrome).
-
-## Packing
-
-After the development of your extension run the command
-
-```
-$ NODE_ENV=production npm run build
-```
-
-Now, the content of `build` folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the [official guide](https://developer.chrome.com/webstore/publish) to more infos about publishing.
-
-## Secrets
-
-If you are developing an extension that talks with some API you probably are using different keys for testing and production. Is a good practice you not commit your secret keys and expose to anyone that have access to the repository.
-
-To this task this boilerplate import the file `./secrets..js` on your modules through the module named as `secrets`, so you can do things like this:
-
-_./secrets.development.js_
-
-```js
-export default { key: '123' };
-```
-
-_./src/popup.js_
-
-```js
-import secrets from 'secrets';
-ApiCall({ key: secrets.key });
-```
-
-:point_right: The files with name `secrets.*.js` already are ignored on the repository.
-
-## Resources:
-
-- [Webpack documentation](https://webpack.js.org/concepts/)
-- [Chrome Extension documentation](https://developer.chrome.com/extensions/getstarted)
-
----
-
-Michael Xieyang Liu | [Website](https://lxieyang.github.io)
From 04c92238f1e5ea13c0239b5a444a44bee16f9675 Mon Sep 17 00:00:00 2001
From: Riky
Date: Tue, 15 Apr 2025 08:14:08 -0700
Subject: [PATCH 02/13] mods to dev tools panel
---
src/pages/Devtools/index.js | 4 ++--
src/pages/Panel/Panel.tsx | 19 ++++++++++++++++++-
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/pages/Devtools/index.js b/src/pages/Devtools/index.js
index 647319a1f..69930b426 100644
--- a/src/pages/Devtools/index.js
+++ b/src/pages/Devtools/index.js
@@ -1,5 +1,5 @@
chrome.devtools.panels.create(
- 'Dev Tools from chrome-extension-boilerplate-react',
+ 'Dev Tools from chrome-extension-boilerplate-react V1.0',
'icon-34.png',
'panel.html'
-);
+);
\ No newline at end of file
diff --git a/src/pages/Panel/Panel.tsx b/src/pages/Panel/Panel.tsx
index 7126ce8a7..91a0cf6be 100644
--- a/src/pages/Panel/Panel.tsx
+++ b/src/pages/Panel/Panel.tsx
@@ -1,10 +1,27 @@
import React from 'react';
import './Panel.css';
+var links = [
+ { endpoint: '/america' },
+ { endpoint: '/canada' },
+ { endpoint: '/norway' },
+ { endpoint: '/bahamas' }
+]
+
const Panel: React.FC = () => {
+
+
+ const listItems = links.map((link) =>
+ {link.endpoint}
+ );
+
return (
-
Dev Tools Panel
+
Dev Tools Panel v1
+
Riky
+
);
};
From 5486e3f47724aa71c767812781fd7e8dd894f43d Mon Sep 17 00:00:00 2001
From: Riky
Date: Tue, 15 Apr 2025 08:42:53 -0700
Subject: [PATCH 03/13] added explanation of changes for dev tools panel
---
README.md | 141 +++---------------------------------------------------
1 file changed, 6 insertions(+), 135 deletions(-)
diff --git a/README.md b/README.md
index 4d5ac098c..74311f411 100755
--- a/README.md
+++ b/README.md
@@ -1,40 +1,3 @@
-
-
-# Chrome Extension (MV3) Boilerplate with React 18 and Webpack 5
-
-[](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
-[](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
-[](https://www.npmjs.com/package/chrome-extension-boilerplate-react)
-
-## Announcements
-
-- Recently updated from **[React](https://reactjs.org)** ~~17~~ to **18**!
-- **_This boilerplate adopts [Manifest V3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/)!_**
- - For V2 users, please check out the [manifest-v2](https://github.com/lxieyang/chrome-extension-boilerplate-react/tree/manifest-v2) branch, or use version [3.x](https://www.npmjs.com/package/chrome-extension-boilerplate-react/v/3.3.0).
- - Check out the [Manifest V3 Migration Guide](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/).
-- Recently added [devtools](https://developer.chrome.com/docs/extensions/mv3/devtools/) Support! Thanks [GeekaholicLin](https://github.com/lxieyang/chrome-extension-boilerplate-react/issues/17)!
-- Recently updated from **[Webpack Dev Server](https://webpack.js.org/configuration/dev-server/)** ~~3.x~~ to **4.x** and **[Webpack](https://webpack.js.org/)** ~~4~~ to **5**!
-- Recently added [TypeScript](https://www.typescriptlang.org/) Support!
-
-## Features
-
-This is a basic Chrome Extensions boilerplate to help you write modular and modern Javascript code, load CSS easily and [automatic reload the browser on code changes](https://webpack.github.io/docs/webpack-dev-server.html#automatic-refresh).
-
-This boilerplate is updated with:
-
-- [Chrome Extension Manifest V3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/)
-- [React 18](https://reactjs.org)
-- [Webpack 5](https://webpack.js.org/)
-- [Webpack Dev Server 4](https://webpack.js.org/configuration/dev-server/)
-- [React Refresh](https://www.npmjs.com/package/react-refresh)
-- [react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin)
-- [eslint-config-react-app](https://www.npmjs.com/package/eslint-config-react-app)
-- [Prettier](https://prettier.io/)
-- [TypeScript](https://www.typescriptlang.org/)
-
-This boilerplate is heavily inspired by and adapted from [https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate), with additional support for React 18 features, Webpack 5, and Webpack Dev Server 4.
-
-Please open up an issue to nudge me to keep the npm packages up-to-date. FYI, it takes time to make different packages with different versions work together nicely.
## Installing and Running
@@ -42,109 +5,17 @@ Please open up an issue to nudge me to keep the npm packages up-to-date. FYI, it
1. Check if your [Node.js](https://nodejs.org/) version is >= **18**.
2. Clone this repository.
-3. Change the package's `name`, `description`, and `repository` fields in `package.json`.
-4. Change the name of your extension on `src/manifest.json`.
-5. Run `npm install` to install the dependencies.
-6. Run `npm start`
-7. Load your extension on Chrome following:
+3. Run `npm install` to install the dependencies.
+4. Run `npm start`
+5. Load your extension on Chrome following:
1. Access `chrome://extensions/`
2. Check `Developer mode`
3. Click on `Load unpacked extension`
4. Select the `build` folder.
-8. Happy hacking.
-
-## Structure
-
-All your extension's code must be placed in the `src` folder.
-
-The boilerplate is already prepared to have a popup, an options page, a background page, and a new tab page (which replaces the new tab page of your browser). But feel free to customize these.
-
-## TypeScript
-
-This boilerplate now supports TypeScript! The `Options` Page is implemented using TypeScript. Please refer to `src/pages/Options/` for example usages.
-
-## Webpack auto-reload and HRM
-
-To make your workflow much more efficient this boilerplate uses the [webpack server](https://webpack.github.io/docs/webpack-dev-server.html) to development (started with `npm start`) with auto reload feature that reloads the browser automatically every time that you save some file in your editor.
-
-You can run the dev mode on other port if you want. Just specify the env var `port` like this:
-
-```
-$ PORT=6002 npm run start
-```
-
-## Content Scripts
-
-Although this boilerplate uses the webpack dev server, it's also prepared to write all your bundles files on the disk at every code change, so you can point, on your extension manifest, to your bundles that you want to use as [content scripts](https://developer.chrome.com/extensions/content_scripts), but you need to exclude these entry points from hot reloading [(why?)](https://github.com/samuelsimoes/chrome-extension-webpack-boilerplate/issues/4#issuecomment-261788690). To do so you need to expose which entry points are content scripts on the `webpack.config.js` using the `chromeExtensionBoilerplate -> notHotReload` config. Look the example below.
-
-Let's say that you want use the `myContentScript` entry point as content script, so on your `webpack.config.js` you will configure the entry point and exclude it from hot reloading, like this:
-
-```js
-{
- …
- entry: {
- myContentScript: "./src/js/myContentScript.js"
- },
- chromeExtensionBoilerplate: {
- notHotReload: ["myContentScript"]
- }
- …
-}
-```
-
-and on your `src/manifest.json`:
-
-```json
-{
- "content_scripts": [
- {
- "matches": ["https://www.google.com/*"],
- "js": ["myContentScript.bundle.js"]
- }
- ]
-}
-```
-
-## Intelligent Code Completion
-
-Thanks to [@hudidit](https://github.com/lxieyang/chrome-extension-boilerplate-react/issues/4)'s kind suggestions, this boilerplate supports chrome-specific intelligent code completion using [@types/chrome](https://www.npmjs.com/package/@types/chrome).
-
-## Packing
-
-After the development of your extension run the command
-
-```
-$ NODE_ENV=production npm run build
-```
-
-Now, the content of `build` folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the [official guide](https://developer.chrome.com/webstore/publish) to more infos about publishing.
-
-## Secrets
-
-If you are developing an extension that talks with some API you probably are using different keys for testing and production. Is a good practice you not commit your secret keys and expose to anyone that have access to the repository.
-
-To this task this boilerplate import the file `./secrets..js` on your modules through the module named as `secrets`, so you can do things like this:
-
-_./secrets.development.js_
-
-```js
-export default { key: '123' };
-```
-
-_./src/popup.js_
-
-```js
-import secrets from 'secrets';
-ApiCall({ key: secrets.key });
-```
-
-:point_right: The files with name `secrets.*.js` already are ignored on the repository.
-## Resources:
-- [Webpack documentation](https://webpack.js.org/concepts/)
-- [Chrome Extension documentation](https://developer.chrome.com/extensions/getstarted)
+### Modifications to deve tools panel
----
+Added static content to dev tools panel in this case it is an array of strings
+and a loop to display the list in the page and changed added a version in the title
-Michael Xieyang Liu | [Website](https://lxieyang.github.io)
From c03c0bab38d1faf4a117b647f89a77163ee25210 Mon Sep 17 00:00:00 2001
From: Riky
Date: Tue, 15 Apr 2025 18:48:33 -0700
Subject: [PATCH 04/13] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 23060d91e..5200c01fe 100755
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
## Installing and Running
-
+x
### Procedures:
1. Check if your [Node.js](https://nodejs.org/) version is >= **18**.
From 0e2a7e484ca21a7d6ca881c17696cdef1460c4cc Mon Sep 17 00:00:00 2001
From: Riky
Date: Tue, 15 Apr 2025 18:49:43 -0700
Subject: [PATCH 05/13] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 5200c01fe..23060d91e 100755
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
## Installing and Running
-x
+
### Procedures:
1. Check if your [Node.js](https://nodejs.org/) version is >= **18**.
From 5539bddb4f878d54098e75aecedb6fdee36abff6 Mon Sep 17 00:00:00 2001
From: Riky
Date: Wed, 16 Apr 2025 07:51:21 -0700
Subject: [PATCH 06/13] changed titles
---
README.md | 2 +-
src/pages/Devtools/index.js | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index e9e1bb707..99c71e308 100755
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
4. Select the `build` folder.
-### Modifications to deve tools panel
+### Dev Tools - Modifications to deve tools panel
Added static content to dev tools panel in this case it is an array of strings
and a loop to display the list in the page and changed added a version in the title
diff --git a/src/pages/Devtools/index.js b/src/pages/Devtools/index.js
index 69930b426..64447201f 100644
--- a/src/pages/Devtools/index.js
+++ b/src/pages/Devtools/index.js
@@ -1,5 +1,5 @@
chrome.devtools.panels.create(
- 'Dev Tools from chrome-extension-boilerplate-react V1.0',
+ 'Request interception tool',
'icon-34.png',
'panel.html'
);
\ No newline at end of file
From a7e12f0ed68e0e8c45dcac21b3c0a51eff6cf1ca Mon Sep 17 00:00:00 2001
From: Riky
Date: Wed, 16 Apr 2025 10:29:53 -0700
Subject: [PATCH 07/13] declarativeWebRequest json modification
---
src/manifest.json | 13 ++++++
src/pages/Background/index.js | 22 ++++++++++
src/pages/Background/modify_response.js | 58 +++++++++++++++++++++++++
src/rules.json | 34 +++++++++++++++
4 files changed, 127 insertions(+)
create mode 100644 src/pages/Background/modify_response.js
create mode 100644 src/rules.json
diff --git a/src/manifest.json b/src/manifest.json
index 9a7ba9080..39fc7b196 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -2,6 +2,19 @@
"manifest_version": 3,
"name": "Chrome Extension with React & Webpack",
"description": "A chrome extension boilerplate built with React 17, Webpack 5, and Webpack Dev Server 4",
+ "permissions": [
+ "declarativeNetRequest"
+ ],
+
+ "declarative_net_request": {
+ "rule_resources": [
+ {
+ "id": "modify_json_response",
+ "enabled": true,
+ "path": "rules.json"
+ }
+ ]
+},
"options_page": "options.html",
"background": { "service_worker": "background.bundle.js" },
"action": {
diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js
index 8943b846f..e2f8ed0fd 100644
--- a/src/pages/Background/index.js
+++ b/src/pages/Background/index.js
@@ -1,2 +1,24 @@
console.log('This is the background page.');
console.log('Put the background scripts here.');
+
+
+chrome.runtime.onInstalled.addListener(() => {
+ console.log('Service worker installed.');
+ });
+
+ chrome.webRequest.onBeforeRequest.addListener(
+ (details) => {
+ // Check if the request URL matches the target URL you want to modify
+ const targetUrl = "https://conisoft.org/cakes/loadvehicles.php"; // Replace with the actual URL
+ if (details.url.startsWith(targetUrl)) {
+ console.log(`Intercepting request to: ${details.url}`);
+ // Redirect the request to the modify_response.js script, passing the original URL
+
+ return { redirectUrl: chrome.runtime.getURL("modify_response.js") + "?url=" + encodeURIComponent(details.url) };
+ }
+ },
+ { urls: [""] }, // Intercept all URLs (for testing, be more specific in production)
+ ["blocking"] // Important: This makes the listener synchronous, so we can modify the response
+ );
+
+
\ No newline at end of file
diff --git a/src/pages/Background/modify_response.js b/src/pages/Background/modify_response.js
new file mode 100644
index 000000000..54e6f3c2c
--- /dev/null
+++ b/src/pages/Background/modify_response.js
@@ -0,0 +1,58 @@
+(async () => {
+ const urlParams = new URLSearchParams(window.location.search);
+ const originalUrl = urlParams.get('url');
+
+ if (!originalUrl) {
+ console.error("Original URL not provided.");
+ return; // Exit if the URL is missing
+ }
+
+ try {
+ const response = await fetch(originalUrl); // Fetch the original resource
+ if (!response.ok) {
+ console.error(`Failed to fetch original resource: ${response.status} ${response.statusText}`);
+ return; // Exit on fetch error
+ }
+
+ const contentType = response.headers.get('Content-Type');
+
+ if (contentType && contentType.includes('application/json')) {
+ // *** MODIFICATION HAPPENS HERE ***
+ // Create a NEW JSON response
+ const modifiedJsonResponse = {
+ "status": "success",
+ "message": "Response overridden by extension!",
+ "data": [
+ { "model": 101, "year": "Modified Item A", "make": 110 },
+ { "model": 102, "year": "Modified Item B", "make": 120 }
+
+ // [{"model":"fgfgfgfg","year":"2000","make":"Nissan "},{"model":"cc","year":"2000","make":"Ford"}
+
+ ]
+ };
+
+ // Convert the modified JSON object to a string
+ const modifiedJsonString = JSON.stringify(modifiedJsonResponse);
+
+ // Create a new Response object with the modified JSON
+ const modifiedResponse = new Response(modifiedJsonString, {
+ status: 200, // OK status
+ headers: { 'Content-Type': 'application/json' } // Set the correct content type
+ });
+
+ // Return the modified response
+ return modifiedResponse;
+ } else {
+ // Handle other content types (important to prevent errors)
+ console.warn(`Content type not handled: ${contentType}. Returning original.`);
+ return response; // Return the original response if it's not JSON
+ }
+ } catch (error) {
+ console.error("Error fetching and modifying response:", error);
+ // Handle errors (e.g., show a message to the user, return a default response)
+ return new Response(JSON.stringify({ error: "Failed to modify response" }), {
+ status: 500,
+ headers: { 'Content-Type': 'application/json' }
+ });
+ }
+ })();
\ No newline at end of file
diff --git a/src/rules.json b/src/rules.json
new file mode 100644
index 000000000..577c7e254
--- /dev/null
+++ b/src/rules.json
@@ -0,0 +1,34 @@
+[
+ {
+ "id": 1,
+ "priority": 1,
+ "action": {
+ "type": "modifyHeaders",
+ "responseHeaders": [
+ {
+ "name": "Content-Type",
+ "value": "application/json"
+ }
+ ]
+ },
+ "condition": {
+ "urlFilter": "https://conisoft.org/cakes/loadvehicles.php",
+ "resourceTypes": ["xmlhttprequest", "fetch"]
+ }
+ },
+ {
+ "id": 2,
+ "priority": 2,
+ "action": {
+ "type": "modifyBody",
+ "response": {
+ "from": "{\"model\":\"fgfgfgfg\",\"year\":\"2000\",\"make\":\"Nissan\"}",
+ "to": " { \"model\": \"101\", \"year\": \"Modified Item A\", \"make\": \"110\" }"
+ }
+ },
+ "condition": {
+ "urlFilter": "https://conisoft.org/cakes/loadvehicles.php",
+ "resourceTypes": ["xmlhttprequest", "fetch"]
+ }
+ }
+]
\ No newline at end of file
From c9704471f6d9abb3062ad7b4fc748cc9b2ca946f Mon Sep 17 00:00:00 2001
From: Riky
Date: Wed, 16 Apr 2025 10:34:50 -0700
Subject: [PATCH 08/13] removed function
---
src/pages/Background/index.js | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js
index e2f8ed0fd..8943b846f 100644
--- a/src/pages/Background/index.js
+++ b/src/pages/Background/index.js
@@ -1,24 +1,2 @@
console.log('This is the background page.');
console.log('Put the background scripts here.');
-
-
-chrome.runtime.onInstalled.addListener(() => {
- console.log('Service worker installed.');
- });
-
- chrome.webRequest.onBeforeRequest.addListener(
- (details) => {
- // Check if the request URL matches the target URL you want to modify
- const targetUrl = "https://conisoft.org/cakes/loadvehicles.php"; // Replace with the actual URL
- if (details.url.startsWith(targetUrl)) {
- console.log(`Intercepting request to: ${details.url}`);
- // Redirect the request to the modify_response.js script, passing the original URL
-
- return { redirectUrl: chrome.runtime.getURL("modify_response.js") + "?url=" + encodeURIComponent(details.url) };
- }
- },
- { urls: [""] }, // Intercept all URLs (for testing, be more specific in production)
- ["blocking"] // Important: This makes the listener synchronous, so we can modify the response
- );
-
-
\ No newline at end of file
From e4738227b3ceb5079e3edc94ecedf460d8355e47 Mon Sep 17 00:00:00 2001
From: Riky
Date: Wed, 16 Apr 2025 10:46:19 -0700
Subject: [PATCH 09/13] unsued file deleted
---
src/pages/Background/modify_response.js | 58 -------------------------
1 file changed, 58 deletions(-)
delete mode 100644 src/pages/Background/modify_response.js
diff --git a/src/pages/Background/modify_response.js b/src/pages/Background/modify_response.js
deleted file mode 100644
index 54e6f3c2c..000000000
--- a/src/pages/Background/modify_response.js
+++ /dev/null
@@ -1,58 +0,0 @@
-(async () => {
- const urlParams = new URLSearchParams(window.location.search);
- const originalUrl = urlParams.get('url');
-
- if (!originalUrl) {
- console.error("Original URL not provided.");
- return; // Exit if the URL is missing
- }
-
- try {
- const response = await fetch(originalUrl); // Fetch the original resource
- if (!response.ok) {
- console.error(`Failed to fetch original resource: ${response.status} ${response.statusText}`);
- return; // Exit on fetch error
- }
-
- const contentType = response.headers.get('Content-Type');
-
- if (contentType && contentType.includes('application/json')) {
- // *** MODIFICATION HAPPENS HERE ***
- // Create a NEW JSON response
- const modifiedJsonResponse = {
- "status": "success",
- "message": "Response overridden by extension!",
- "data": [
- { "model": 101, "year": "Modified Item A", "make": 110 },
- { "model": 102, "year": "Modified Item B", "make": 120 }
-
- // [{"model":"fgfgfgfg","year":"2000","make":"Nissan "},{"model":"cc","year":"2000","make":"Ford"}
-
- ]
- };
-
- // Convert the modified JSON object to a string
- const modifiedJsonString = JSON.stringify(modifiedJsonResponse);
-
- // Create a new Response object with the modified JSON
- const modifiedResponse = new Response(modifiedJsonString, {
- status: 200, // OK status
- headers: { 'Content-Type': 'application/json' } // Set the correct content type
- });
-
- // Return the modified response
- return modifiedResponse;
- } else {
- // Handle other content types (important to prevent errors)
- console.warn(`Content type not handled: ${contentType}. Returning original.`);
- return response; // Return the original response if it's not JSON
- }
- } catch (error) {
- console.error("Error fetching and modifying response:", error);
- // Handle errors (e.g., show a message to the user, return a default response)
- return new Response(JSON.stringify({ error: "Failed to modify response" }), {
- status: 500,
- headers: { 'Content-Type': 'application/json' }
- });
- }
- })();
\ No newline at end of file
From f4e2188cdb44e9e10cc40f0d1a1787bd47226b7b Mon Sep 17 00:00:00 2001
From: Riky
Date: Wed, 16 Apr 2025 14:13:36 -0700
Subject: [PATCH 10/13] changed server conn to ws
---
src/pages/Background/index.js | 2 +-
utils/webserver.js | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js
index 8943b846f..6b423e600 100644
--- a/src/pages/Background/index.js
+++ b/src/pages/Background/index.js
@@ -1,2 +1,2 @@
console.log('This is the background page.');
-console.log('Put the background scripts here.');
+console.log('Put the background scripts here.');
\ No newline at end of file
diff --git a/utils/webserver.js b/utils/webserver.js
index 90faaa83e..30be964b8 100755
--- a/utils/webserver.js
+++ b/utils/webserver.js
@@ -27,20 +27,20 @@ var compiler = webpack(config);
var server = new WebpackDevServer(
{
- https: false,
+ https: true,
hot: true,
liveReload: false,
client: {
- webSocketTransport: 'sockjs',
+ webSocketTransport: 'ws',
},
- webSocketServer: 'sockjs',
+ webSocketServer: 'ws',
host: 'localhost',
port: env.PORT,
static: {
directory: path.join(__dirname, '../build'),
},
devMiddleware: {
- publicPath: `http://localhost:${env.PORT}/`,
+ publicPath: `wss://localhost:${env.PORT}/`,
writeToDisk: true,
},
headers: {
From a2f6baeaabf4995dbf241a3a0c88bb8cae766037 Mon Sep 17 00:00:00 2001
From: Riky
Date: Wed, 16 Apr 2025 15:12:38 -0700
Subject: [PATCH 11/13] changed wesocket
---
utils/webserver.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/utils/webserver.js b/utils/webserver.js
index 30be964b8..03d1774b4 100755
--- a/utils/webserver.js
+++ b/utils/webserver.js
@@ -31,9 +31,9 @@ var server = new WebpackDevServer(
hot: true,
liveReload: false,
client: {
- webSocketTransport: 'ws',
+ webSocketTransport: 'sockjs',
},
- webSocketServer: 'ws',
+ webSocketServer: 'sockjs',
host: 'localhost',
port: env.PORT,
static: {
From 3bec5df7889c099495ba2a62ebf2bb20badc4cd6 Mon Sep 17 00:00:00 2001
From: Riky
Date: Wed, 16 Apr 2025 17:36:45 -0700
Subject: [PATCH 12/13] permissions and rule modifications
---
src/manifest.json | 7 +++++--
src/rules.json | 15 +++++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/manifest.json b/src/manifest.json
index 39fc7b196..f052bfb87 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -3,9 +3,12 @@
"name": "Chrome Extension with React & Webpack",
"description": "A chrome extension boilerplate built with React 17, Webpack 5, and Webpack Dev Server 4",
"permissions": [
- "declarativeNetRequest"
+ "declarativeNetRequest",
+ "declarativeNetRequestFeedback"
],
-
+ "host_permissions": [
+ "https://conisoft.org/*"
+],
"declarative_net_request": {
"rule_resources": [
{
diff --git a/src/rules.json b/src/rules.json
index 577c7e254..7d10936f5 100644
--- a/src/rules.json
+++ b/src/rules.json
@@ -13,7 +13,7 @@
},
"condition": {
"urlFilter": "https://conisoft.org/cakes/loadvehicles.php",
- "resourceTypes": ["xmlhttprequest", "fetch"]
+ "resourceTypes": ["xmlhttprequest", "fetch","main_frame","websocket"]
}
},
{
@@ -28,7 +28,18 @@
},
"condition": {
"urlFilter": "https://conisoft.org/cakes/loadvehicles.php",
- "resourceTypes": ["xmlhttprequest", "fetch"]
+ "resourceTypes": ["xmlhttprequest", "fetch", "main_frame", "websocket"]
+ }
+ },
+ {
+ "id" : 3,
+ "priority": 2,
+ "action" : {
+ "type" : "allowAllRequests"
+ },
+ "condition" : {
+ "urlFilter" : "||conisoft.org/*",
+ "resourceTypes" : ["main_frame"]
}
}
]
\ No newline at end of file
From 4a0f53b3dda193c3d2210b787d868c0b94918c35 Mon Sep 17 00:00:00 2001
From: Riky
Date: Fri, 18 Apr 2025 15:07:21 -0700
Subject: [PATCH 13/13] any domain permission added
---
src/manifest.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/manifest.json b/src/manifest.json
index f052bfb87..a5f1c9013 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -7,7 +7,7 @@
"declarativeNetRequestFeedback"
],
"host_permissions": [
- "https://conisoft.org/*"
+ "*://*/"
],
"declarative_net_request": {
"rule_resources": [