diff --git a/package.json b/package.json
index 424bf17..d9df001 100755
--- a/package.json
+++ b/package.json
@@ -1,11 +1,11 @@
{
- "name": "chrome-extension-boilerplate-react",
- "version": "4.3.5",
- "description": "A chrome extension boilerplate built with React 17, Webpack 5, and Webpack Dev Server 4",
+ "name": "vytal",
+ "version": "1.0.0",
+ "description": "Vytal",
"license": "MIT",
"repository": {
"type": "git",
- "url": "https://github.com/lxieyang/chrome-extension-boilerplate-react.git"
+ "url": "https://github.com/z0ccc/Vytal.git"
},
"scripts": {
"build": "node utils/build.js",
diff --git a/src/assets/img/icon-128.png b/src/assets/img/icon-128.png
index 13996e6..4001c28 100644
Binary files a/src/assets/img/icon-128.png and b/src/assets/img/icon-128.png differ
diff --git a/src/assets/img/icon-32.png b/src/assets/img/icon-32.png
new file mode 100644
index 0000000..63ec286
Binary files /dev/null and b/src/assets/img/icon-32.png differ
diff --git a/src/assets/img/icon-34.png b/src/assets/img/icon-34.png
deleted file mode 100644
index 96aba0b..0000000
Binary files a/src/assets/img/icon-34.png and /dev/null differ
diff --git a/src/manifest.json b/src/manifest.json
index 9a7ba90..6efffda 100755
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,15 +1,13 @@
{
"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",
+ "name": "Vytal",
+ "description": "Vytal",
"options_page": "options.html",
+ "permissions": ["debugger", "activeTab"],
"background": { "service_worker": "background.bundle.js" },
"action": {
"default_popup": "popup.html",
- "default_icon": "icon-34.png"
- },
- "chrome_url_overrides": {
- "newtab": "newtab.html"
+ "default_icon": "icon-32.png"
},
"icons": {
"128": "icon-128.png"
@@ -21,10 +19,9 @@
"css": ["content.styles.css"]
}
],
- "devtools_page": "devtools.html",
"web_accessible_resources": [
{
- "resources": ["content.styles.css", "icon-128.png", "icon-34.png"],
+ "resources": ["content.styles.css", "icon-128.png", "icon-32.png"],
"matches": []
}
]
diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js
index 8943b84..934e475 100644
--- a/src/pages/Background/index.js
+++ b/src/pages/Background/index.js
@@ -1,2 +1,71 @@
-console.log('This is the background page.');
-console.log('Put the background scripts here.');
+const attachTab = (tabId) =>{
+ chrome.debugger.attach({ tabId: tabId }, "1.3", function () {
+ if (!chrome.runtime.lastError) {
+ // console.log("attached debugger to tab: " + tabId);
+ // // https://chromedevtools.github.io/devtools-protocol/tot/ - "geolocation"
+
+ chrome.debugger.sendCommand(
+ { tabId: tabId },
+ "Emulation.setTimezoneOverride",
+ { timezoneId: "Asia/Shanghai" }
+ );
+
+ chrome.debugger.sendCommand(
+ { tabId: tabId },
+ "Emulation.setLocaleOverride",
+ { locale: "zh-Hans-CN" }
+ );
+
+ const london = {
+ latitude: 31.230416,
+ longitude: 121.473701,
+ accuracy: 1,
+ };
+ chrome.debugger.sendCommand(
+ { tabId: tabId },
+ "Emulation.setGeolocationOverride",
+ london,
+ function (result) {
+ console.log(result);
+ }
+ );
+ // chrome.debugger.sendCommand(
+ // { tabId: tabId },
+ // "Emulation.setUserAgentOverride",
+ // {
+ // userAgent:
+ // "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.35",
+ // },
+ // { acceptLanguage: "mr-IN" }
+ // );
+
+ // chrome.debugger.sendCommand(
+ // { tabId: tabId },
+ // "[Emulation.setLocaleOverride](https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setLocaleOverride)",
+ // { locale: "mr-IN" }
+ // );
+ //chrome.debugger.sendCommand({tabId: tabId}, "Emulation.clearGeolocationOverride");
+ // chrome.debugger.detach({ tabId: tabId });
+ }
+ });
+}
+
+// Detects if there are posts for current url
+chrome.tabs.onUpdated.addListener((tabId, change, tab) => {
+ attachTab(tabId);
+});
+
+// chrome.tabs.onUpdated.addListener((tabId, change, tab) => {
+// chrome.debugger.attach({ tabId: tabId }, "1.3", function () {
+// if (!chrome.runtime.lastError) {
+// // console.log("attached debugger to tab: " + tabId);
+// // // https://chromedevtools.github.io/devtools-protocol/tot/ - "geolocation"
+
+// chrome.debugger.sendCommand(
+// { tabId: tabId },
+// "Emulation.setTimezoneOverride",
+// { timezoneId: "Asia/Shanghai" }
+// );
+// }
+// });
+// });
\ No newline at end of file
diff --git a/src/pages/Devtools/index.html b/src/pages/Devtools/index.html
deleted file mode 100644
index a47b2fe..0000000
--- a/src/pages/Devtools/index.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/Devtools/index.js b/src/pages/Devtools/index.js
deleted file mode 100644
index 647319a..0000000
--- a/src/pages/Devtools/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-chrome.devtools.panels.create(
- 'Dev Tools from chrome-extension-boilerplate-react',
- 'icon-34.png',
- 'panel.html'
-);
diff --git a/src/pages/Newtab/Newtab.css b/src/pages/Newtab/Newtab.css
deleted file mode 100644
index 74b5e05..0000000
--- a/src/pages/Newtab/Newtab.css
+++ /dev/null
@@ -1,38 +0,0 @@
-.App {
- text-align: center;
-}
-
-.App-logo {
- height: 40vmin;
- pointer-events: none;
-}
-
-@media (prefers-reduced-motion: no-preference) {
- .App-logo {
- animation: App-logo-spin infinite 20s linear;
- }
-}
-
-.App-header {
- background-color: #282c34;
- min-height: 100vh;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- font-size: calc(10px + 2vmin);
- color: white;
-}
-
-.App-link {
- color: #61dafb;
-}
-
-@keyframes App-logo-spin {
- from {
- transform: rotate(0deg);
- }
- to {
- transform: rotate(360deg);
- }
-}
diff --git a/src/pages/Newtab/Newtab.jsx b/src/pages/Newtab/Newtab.jsx
deleted file mode 100644
index 6ed464f..0000000
--- a/src/pages/Newtab/Newtab.jsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import React from 'react';
-import logo from '../../assets/img/logo.svg';
-import './Newtab.css';
-import './Newtab.scss';
-
-const Newtab = () => {
- return (
-
- );
-};
-
-export default Newtab;
diff --git a/src/pages/Newtab/Newtab.scss b/src/pages/Newtab/Newtab.scss
deleted file mode 100644
index 8960c7b..0000000
--- a/src/pages/Newtab/Newtab.scss
+++ /dev/null
@@ -1,10 +0,0 @@
-$myColor: red;
-
-h1,
-h2,
-h3,
-h4,
-h5,
-h6 {
- color: $myColor;
-}
diff --git a/src/pages/Newtab/index.css b/src/pages/Newtab/index.css
deleted file mode 100644
index ec2585e..0000000
--- a/src/pages/Newtab/index.css
+++ /dev/null
@@ -1,13 +0,0 @@
-body {
- margin: 0;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
- sans-serif;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
-}
-
-code {
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
- monospace;
-}
diff --git a/src/pages/Newtab/index.html b/src/pages/Newtab/index.html
deleted file mode 100644
index ae663d1..0000000
--- a/src/pages/Newtab/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- Chrome Extension Boilerplate (with React 16.6+ & Webpack 4+)
-
-
-
-
-
-
diff --git a/src/pages/Newtab/index.jsx b/src/pages/Newtab/index.jsx
deleted file mode 100644
index 8466732..0000000
--- a/src/pages/Newtab/index.jsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-import { render } from 'react-dom';
-
-import Newtab from './Newtab';
-import './index.css';
-
-render(, window.document.querySelector('#app-container'));
-
-if (module.hot) module.hot.accept();
diff --git a/src/pages/Panel/Panel.css b/src/pages/Panel/Panel.css
deleted file mode 100644
index 843f23e..0000000
--- a/src/pages/Panel/Panel.css
+++ /dev/null
@@ -1,7 +0,0 @@
-body {
- background-color: #242424;
-}
-
-.container {
- color: #ffffff;
-}
\ No newline at end of file
diff --git a/src/pages/Panel/Panel.tsx b/src/pages/Panel/Panel.tsx
deleted file mode 100644
index 7126ce8..0000000
--- a/src/pages/Panel/Panel.tsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import React from 'react';
-import './Panel.css';
-
-const Panel: React.FC = () => {
- return (
-
-
Dev Tools Panel
-
- );
-};
-
-export default Panel;
diff --git a/src/pages/Panel/index.css b/src/pages/Panel/index.css
deleted file mode 100644
index e69de29..0000000
diff --git a/src/pages/Panel/index.html b/src/pages/Panel/index.html
deleted file mode 100644
index 7eee39a..0000000
--- a/src/pages/Panel/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- Dev Tools Panel
-
-
-
-
-
-
diff --git a/src/pages/Panel/index.jsx b/src/pages/Panel/index.jsx
deleted file mode 100644
index 08eb322..0000000
--- a/src/pages/Panel/index.jsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-import { render } from 'react-dom';
-
-import Panel from './Panel';
-import './index.css';
-
-render(, window.document.querySelector('#app-container'));
-
-if (module.hot) module.hot.accept();
diff --git a/src/pages/Popup/Popup.jsx b/src/pages/Popup/Popup.jsx
index d0dff8e..3f63bef 100644
--- a/src/pages/Popup/Popup.jsx
+++ b/src/pages/Popup/Popup.jsx
@@ -1,6 +1,6 @@
import React from 'react';
import logo from '../../assets/img/logo.svg';
-import Greetings from '../../containers/Greetings/Greetings';
+// import Greetings from '../../containers/Greetings/Greetings';
import './Popup.css';
const Popup = () => {
diff --git a/webpack.config.js b/webpack.config.js
index ac9267c..fe14a7a 100755
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -36,16 +36,13 @@ if (fileSystem.existsSync(secretsPath)) {
var options = {
mode: process.env.NODE_ENV || 'development',
entry: {
- newtab: path.join(__dirname, 'src', 'pages', 'Newtab', 'index.jsx'),
options: path.join(__dirname, 'src', 'pages', 'Options', 'index.jsx'),
popup: path.join(__dirname, 'src', 'pages', 'Popup', 'index.jsx'),
background: path.join(__dirname, 'src', 'pages', 'Background', 'index.js'),
contentScript: path.join(__dirname, 'src', 'pages', 'Content', 'index.js'),
- devtools: path.join(__dirname, 'src', 'pages', 'Devtools', 'index.js'),
- panel: path.join(__dirname, 'src', 'pages', 'Panel', 'index.jsx'),
},
chromeExtensionBoilerplate: {
- notHotReload: ['background', 'contentScript', 'devtools'],
+ notHotReload: ['background', 'contentScript'],
},
output: {
filename: '[name].bundle.js',
@@ -154,18 +151,12 @@ var options = {
new CopyWebpackPlugin({
patterns: [
{
- from: 'src/assets/img/icon-34.png',
+ from: 'src/assets/img/icon-32.png',
to: path.join(__dirname, 'build'),
force: true,
},
],
}),
- new HtmlWebpackPlugin({
- template: path.join(__dirname, 'src', 'pages', 'Newtab', 'index.html'),
- filename: 'newtab.html',
- chunks: ['newtab'],
- cache: false,
- }),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'pages', 'Options', 'index.html'),
filename: 'options.html',
@@ -178,18 +169,6 @@ var options = {
chunks: ['popup'],
cache: false,
}),
- new HtmlWebpackPlugin({
- template: path.join(__dirname, 'src', 'pages', 'Devtools', 'index.html'),
- filename: 'devtools.html',
- chunks: ['devtools'],
- cache: false,
- }),
- new HtmlWebpackPlugin({
- template: path.join(__dirname, 'src', 'pages', 'Panel', 'index.html'),
- filename: 'panel.html',
- chunks: ['panel'],
- cache: false,
- }),
],
infrastructureLogging: {
level: 'info',