diff --git a/background/index.js b/background/index.js deleted file mode 100644 index 63caf8d..0000000 --- a/background/index.js +++ /dev/null @@ -1,22 +0,0 @@ -chrome.runtime.onInstalled.addListener(function (object) { - if (object.reason === chrome.runtime.OnInstalledReason.INSTALL) { - chrome.tabs.create({ url: "https://clydedsouza.net" }); - } -}); - -chrome.commands.onCommand.addListener((command) => { - if(command === 'turn-on') { - chrome.action.setBadgeText({ text: 'ON' }); - chrome.action.setBadgeBackgroundColor({ color: 'green' }); - } - if(command === 'turn-off') { - chrome.action.setBadgeText({ text: 'OFF' }); - chrome.action.setBadgeBackgroundColor({ color: 'red' }); - } -}); - -chrome.omnibox.onInputEntered.addListener((text) => { - chrome.tabs.create({ url: 'https://facebook.com/' + encodeURIComponent(text) }); - chrome.tabs.create({ url: 'https://twitter.com/' + encodeURIComponent(text) }); - chrome.tabs.create({ url: 'https://instagram.com/' + encodeURIComponent(text) }); -}); \ No newline at end of file diff --git a/common/settings.js b/common/settings.js deleted file mode 100644 index ba9904f..0000000 --- a/common/settings.js +++ /dev/null @@ -1,5 +0,0 @@ -export const CHROME_SYNC_STORAGE_KEY = "chrome-extension-template"; - -export const PRESET_CONFIGURATION = { - "storageValue": "https://clydedsouza.net", -}; diff --git a/common/settings.test.js b/common/settings.test.js deleted file mode 100644 index aad8a77..0000000 --- a/common/settings.test.js +++ /dev/null @@ -1,10 +0,0 @@ -import * as settingsModule from "./settings"; - -describe("settings", () => { - test("has a preset configuration key", () => { - const presetConfig = settingsModule.PRESET_CONFIGURATION; - const keys = Object.keys(presetConfig); - expect(keys.length).toBe(1); - expect(presetConfig["storageValue"]).toBe("https://clydedsouza.net"); - }); -}); diff --git a/common/storage.js b/common/storage.js deleted file mode 100644 index 239aa85..0000000 --- a/common/storage.js +++ /dev/null @@ -1,9 +0,0 @@ -export const getStorage = (componentKey, callback) => { - chrome.storage.sync.get([componentKey], function(result) { - callback(result[componentKey]); - }); -}; - -export const setStorage = (componentKey, value) => { - chrome.storage.sync.set({[componentKey]: value}); -}; \ No newline at end of file diff --git a/common/storage.test.js b/common/storage.test.js deleted file mode 100644 index 656bf98..0000000 --- a/common/storage.test.js +++ /dev/null @@ -1,42 +0,0 @@ -import * as storageModule from "./storage"; - -const get = jest.fn(); -const set = jest.fn(); - -global.chrome = { - storage: { - sync: { - set, - get - } - } -}; - -const chromeGetStorageSpy = jest.spyOn(chrome.storage.sync, 'get'); -const chromeSetStorageSpy = jest.spyOn(chrome.storage.sync, 'set'); - -describe("storage → getStorage", () => { - beforeEach(() => { - jest.resetAllMocks(); - }); - - test("chrome get storage api method called", () => { - const getCallback = jest.fn(); - - storageModule.getStorage("Test", getCallback); - - expect(chromeGetStorageSpy).toHaveBeenCalledWith(["Test"], expect.any(Function)); - }); -}); - -describe("storage → setStorage", () => { - beforeEach(() => { - jest.resetAllMocks(); - }); - - test("chrome set storage api method called", () => { - storageModule.setStorage("Test", "Value"); - - expect(chromeSetStorageSpy).toHaveBeenCalledWith({["Test"]: "Value"}); - }); -}); diff --git a/content_scripts/index.js b/content_scripts/index.js deleted file mode 100644 index b50340f..0000000 --- a/content_scripts/index.js +++ /dev/null @@ -1,13 +0,0 @@ -import { getStorage } from "../common/storage"; -import { CHROME_SYNC_STORAGE_KEY, PRESET_CONFIGURATION } from "../common/settings"; - -function loadAndDisplayStorageValue(result) { - const savedConfiguration = result || PRESET_CONFIGURATION; - const storageValue = savedConfiguration["storageValue"]; - console.info("Storage value is", storageValue); -} - -window.onload = function() { - console.info("Content script loaded"); - getStorage(CHROME_SYNC_STORAGE_KEY, loadAndDisplayStorageValue); -} diff --git a/icons/icon128.png b/icons/icon128.png deleted file mode 100644 index ef76857..0000000 Binary files a/icons/icon128.png and /dev/null differ diff --git a/icons/icon16.png b/icons/icon16.png deleted file mode 100644 index 14bd54f..0000000 Binary files a/icons/icon16.png and /dev/null differ diff --git a/icons/icon48.png b/icons/icon48.png deleted file mode 100644 index 6d18b47..0000000 Binary files a/icons/icon48.png and /dev/null differ diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 6076fbc..0000000 --- a/manifest.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "manifest_version": 3, - "name": "Chrome Extension Template", - "description": "A Chrome Extension created using a template", - "version": "0.0.1", - "author": "Clyde D'Souza", - "icons": { - "16": "icons/icon16.png", - "48": "icons/icon48.png", - "128": "icons/icon128.png" - }, - "omnibox": { - "keyword" : "@@" - }, - "permissions": [ - "storage" - ], - "chrome_url_overrides" : { - "newtab": "newtab.html" - }, - "options_ui": { - "page": "options.html", - "open_in_tab": true - }, - "background": { - "service_worker": "background.js" - }, - "content_scripts": [{ - "matches": ["*://github.com/*"], - "js": ["content_scripts.js"] - }], - "action": { - "default_popup": "popup.html", - "default_title": "Open template popup" - }, - "commands": { - "turn-on": { - "suggested_key": { - "default": "Alt + Shift + M" - }, - "description": "Adds an ON badge to the action icon." - }, - "turn-off": { - "suggested_key": { - "default": "Alt + Shift + N" - }, - "description": "Adds an OFF badge to the action icon." - }, - "_execute_action": { - "suggested_key": { - "default": "Alt + Shift + L" - } - } - } - } - \ No newline at end of file diff --git a/newtab/newtab.html b/newtab/newtab.html deleted file mode 100644 index c6e59bf..0000000 --- a/newtab/newtab.html +++ /dev/null @@ -1,11 +0,0 @@ - -
- -