From fa8316a94c092e986b4b2616f1992ee2a3eec01a Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Fri, 12 Jul 2019 19:59:42 +0530 Subject: Initial Commit :tada: * Adds Manifest for Extension * Adds barebone messaging from extension and front-end * Adds .env to run react app under CSP --- public/background.js | 24 ++++++++++++++++++++++++ public/content_script.js | 27 +++++++++++++++++++++++++++ public/index.html | 26 ++------------------------ public/manifest.json | 28 +++++++++++++++------------- public/page.html | 16 ++++++++++++++++ 5 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 public/background.js create mode 100644 public/content_script.js create mode 100644 public/page.html (limited to 'public') diff --git a/public/background.js b/public/background.js new file mode 100644 index 0000000..f94c039 --- /dev/null +++ b/public/background.js @@ -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}) + }); + +} \ No newline at end of file diff --git a/public/content_script.js b/public/content_script.js new file mode 100644 index 0000000..612ecf5 --- /dev/null +++ b/public/content_script.js @@ -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" + }); + }) + + + + +})(); + + + + diff --git a/public/index.html b/public/index.html index dd1ccfd..4c5a273 100644 --- a/public/index.html +++ b/public/index.html @@ -5,34 +5,12 @@ - - - - React App + + Bookmark Arranger
- diff --git a/public/manifest.json b/public/manifest.json index 1f2f141..72678e3 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -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": {} +} \ No newline at end of file diff --git a/public/page.html b/public/page.html new file mode 100644 index 0000000..66f4a9d --- /dev/null +++ b/public/page.html @@ -0,0 +1,16 @@ + + + + + + + Document + + +

Ola

+
+ + + + + \ No newline at end of file -- cgit v1.2.3