diff --git a/background.js b/background.js deleted file mode 100644 index 6f71ebe..0000000 --- a/background.js +++ /dev/null @@ -1,94 +0,0 @@ -async function Clicked() { - const { token, url } = await browser.storage.local.get(['token', 'url']); - console.log(`Token: ${token}, URL: ${url}`); - /* - let site_url = document.URL.endsWith('/') ? - document.URL.slice(0, -1) : - document.URL; - */ - // let mealie = "http://localhost:8080"; - - // Pull current site's URL - let [tab] = await browser.tabs.query({active: true, currentWindow: true}); - let site_url = tab.url.endsWith('/') ? - tab.url.slice(0, -1) : - tab.url; - - let mealie = url; - // let group_slug = "" // Change this to your group slug. You can obtain this from your URL after logging-in to Mealie - // let use_keywords= "&use_keywords=0" // Optional - use keywords from recipe - update to "" if you don't want that - // let edity = "&edit=0" // Optional - keep in edit mode - update to "" if you don't want that - - if (mealie.slice(-1) === "/") { - mealie = mealie.slice(0, -1) - } - let dest = mealie + "/recipe/create/url?recipe_import_url=" + site_url; - - // Send a message to the content script - browser.tabs.query({active: true, currentWindow: true}, (tabs) => { - console.log("Sending message to content script"); - browser.tabs.sendMessage(tabs[0].id, `Token: ${token}, URL: ${url}`).then(() => { - console.log("Message sent to content script"); - }).catch((error) => { - console.error("Error sending message to content script:", error); - }); - }); - - /* - // Open a new tab with the destination URL - browser.tabs.create({ url: dest }).then(() => { - console.log(`New tab opened with URL: ${dest}`); - }).catch((error) => { - console.error("Error opening new tab:", error); - }); - */ - - // Submit POST request - const postUrl = `${mealie}/api/recipes/create/url`; - const requestBody = { - includeTags: true, - url: site_url - }; - - const response = await fetch(postUrl, { - method: "POST", - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - }, - body: JSON.stringify(requestBody) - }); - - if (response.ok) { - const responseData = await response.json(); - console.log("POST request successful:", responseData); - } else { - const errorText = await response.text(); - console.error("POST request failed:", response.statusTextm, errorText); - } -} - -// background.js - -// Create a context menu item -browser.contextMenus.create({ - id: "clickHere", - title: "Add to Mealie", - contexts: ["all"], -}); - -// Add a listener for the context menu item -browser.contextMenus.onClicked.addListener((info, tab) => { - console.log("click 1"); - if (info.menuItemId === "clickHere") { - console.log("click 2"); - Clicked(); - } -}); - -// Add a listener for the keyboard shortcut -browser.commands.onCommand.addListener((command) => { - if (command === "activateClick") { - Clicked(); - } -}); diff --git a/content.js b/content.js deleted file mode 100644 index 50362ec..0000000 --- a/content.js +++ /dev/null @@ -1,7 +0,0 @@ -// content.js - -console.log("Content.js is loaded"); - -browser.runtime.onMessage.addListener((message) => { - console.log(`Received message: ${message}`); -}); diff --git a/icons/48.png b/icons/48.png deleted file mode 100644 index ac66efa..0000000 Binary files a/icons/48.png and /dev/null differ diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 8966999..0000000 --- a/manifest.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "manifest_version": 2, - "name": "Mealie", - "version": "1.0", - - "description": "Connects with a local Mealie instance.", - - "icons": { - "48": "icons/48.png" - }, - - "background": { - "scripts": ["background.js"] - }, - "permissions": [ - "webRequest", - "*://mealie.seans.pro/*", - "contextMenus", - "storage", - "activeTab" - ], - "commands": { - "activateClick": { - "suggested_key": { - "default": "Ctrl+Alt+M" - }, - "description": "Activates 'Clicked' function" - } - }, - "options_ui": { - "page": "options.html", - "open_in_tab": true - }, - "content_scripts": [ - { - "matches": [""], - "js": ["content.js"] - } - ] -} \ No newline at end of file diff --git a/options.html b/options.html deleted file mode 100644 index 4f2a127..0000000 --- a/options.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Mealie Extension Options - - -

Extension Options

- -
- -
- - - - - diff --git a/options.js b/options.js deleted file mode 100644 index 534dac4..0000000 --- a/options.js +++ /dev/null @@ -1,16 +0,0 @@ -// options.js - -document.getElementById('save').addEventListener("click", async () => { - const token = document.getElementById('token').value; - const url = document.getElementById('url').value; - - await browser.storage.local.set({ token, url }); - alert('Options saved!'); -}); - -// Load saved settings if they exist -(async () => { - const { token, url } = await browser.storage.local.get(['token', 'url']); - if (token) document.getElementById('token').value = token; - if (url) document.getElementById('url').value = url; -})();