diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6f66c74..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.zip \ No newline at end of file diff --git a/extension/background.js b/extension/background.js index 40b8f2f..6f71ebe 100644 --- a/extension/background.js +++ b/extension/background.js @@ -1,24 +1,20 @@ async function Clicked() { - // Grabs our Token and URL from the Preferences page 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}); - // removes a traling forward slash let site_url = tab.url.endsWith('/') ? tab.url.slice(0, -1) : tab.url; - let mealie_url = url; - - /*** - * NO LONGER USED - * Was originally designed based off of the bookmarklet example on Mealie's GitHub - * - * - let site_url = document.URL.endsWith('/') ? - document.URL.slice(0, -1) : - document.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 @@ -38,19 +34,19 @@ async function Clicked() { }); }); + /* // 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 to your Mealie server - const postUrl = `${mealie_url}/api/recipes/create/url`; + // Submit POST request + const postUrl = `${mealie}/api/recipes/create/url`; const requestBody = { - includeTags: false, + includeTags: true, url: site_url }; @@ -83,7 +79,9 @@ browser.contextMenus.create({ // 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(); } }); diff --git a/extension/content.js b/extension/content.js new file mode 100644 index 0000000..50362ec --- /dev/null +++ b/extension/content.js @@ -0,0 +1,7 @@ +// content.js + +console.log("Content.js is loaded"); + +browser.runtime.onMessage.addListener((message) => { + console.log(`Received message: ${message}`); +}); diff --git a/extension/manifest.json b/extension/manifest.json index ddb6f3d..8966999 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -30,5 +30,11 @@ "options_ui": { "page": "options.html", "open_in_tab": true - } + }, + "content_scripts": [ + { + "matches": [""], + "js": ["content.js"] + } + ] } \ No newline at end of file