Compare commits

..

No commits in common. "560f5706ccb33b9af3ecbad08ca6f9aaee0a9bd8" and "3d8f87b0b6572d7ff4e8ff363d174a263c215a9e" have entirely different histories.

4 changed files with 28 additions and 18 deletions

1
.gitignore vendored
View file

@ -1 +0,0 @@
*.zip

View file

@ -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();
}
});

7
extension/content.js Normal file
View file

@ -0,0 +1,7 @@
// content.js
console.log("Content.js is loaded");
browser.runtime.onMessage.addListener((message) => {
console.log(`Received message: ${message}`);
});

View file

@ -30,5 +30,11 @@
"options_ui": {
"page": "options.html",
"open_in_tab": true
}
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}