Initial Commit
🎉
* Adds Manifest for Extension
* Adds barebone messaging from extension and front-end
* Adds .env to run react app under CSP
This commit is contained in:
24
public/background.js
Normal file
24
public/background.js
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
chrome.browserAction.onClicked.addListener( (tab) =>{
|
||||
chrome.tabs.create({ 'url': chrome.extension.getURL('index.html') }, (tab) => {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
chrome.runtime.onConnect.addListener(port => {
|
||||
port.onMessage.addListener(message => {
|
||||
/* Perform an action if the message meets our criteria */
|
||||
if (message.code === "getBookMarks") {
|
||||
getBookMarks(port)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
getBookMarks = (port) => {
|
||||
chrome.bookmarks.getTree(function (data) {
|
||||
port.postMessage({ bookMarkData: data})
|
||||
});
|
||||
|
||||
}
|
||||
27
public/content_script.js
Normal file
27
public/content_script.js
Normal file
@@ -0,0 +1,27 @@
|
||||
(function(){
|
||||
|
||||
/* Open port on popup file */
|
||||
const port = chrome.runtime.connect({
|
||||
name: "bookmarkArranger"
|
||||
});
|
||||
|
||||
/* Listen for messages on the port */
|
||||
port.onMessage.addListener(message => {
|
||||
console.log(message)
|
||||
});
|
||||
|
||||
document.getElementById('sendMessage').addEventListener('click', ()=>{
|
||||
/* Send a message through the port */
|
||||
port.postMessage({
|
||||
code: "getBookMarks"
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
})();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,34 +5,12 @@
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<title>Bookmark Arranger</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
}
|
||||
"short_name": "Bookmark Arranger",
|
||||
"name": "Bookmark Arranger",
|
||||
"version": "1.0",
|
||||
"description": "Bookmark Arrange",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"scripts": [
|
||||
"background.js"
|
||||
],
|
||||
"persistent": false
|
||||
},
|
||||
"permissions": [
|
||||
"bookmarks"
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
"browser_action": {}
|
||||
}
|
||||
16
public/page.html
Normal file
16
public/page.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Ola</h2>
|
||||
<div id="renderArea"></div>
|
||||
<button id="sendMessage">Send Message</button>
|
||||
|
||||
<script src="./content_script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user