Compare commits
No commits in common. "560f5706ccb33b9af3ecbad08ca6f9aaee0a9bd8" and "3d8f87b0b6572d7ff4e8ff363d174a263c215a9e" have entirely different histories.
560f5706cc
...
3d8f87b0b6
4 changed files with 28 additions and 18 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
*.zip
|
|
|
@ -1,24 +1,20 @@
|
||||||
async function Clicked() {
|
async function Clicked() {
|
||||||
// Grabs our Token and URL from the Preferences page
|
|
||||||
const { token, url } = await browser.storage.local.get(['token', 'url']);
|
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
|
// Pull current site's URL
|
||||||
let [tab] = await browser.tabs.query({active: true, currentWindow: true});
|
let [tab] = await browser.tabs.query({active: true, currentWindow: true});
|
||||||
// removes a traling forward slash
|
|
||||||
let site_url = tab.url.endsWith('/') ?
|
let site_url = tab.url.endsWith('/') ?
|
||||||
tab.url.slice(0, -1) :
|
tab.url.slice(0, -1) :
|
||||||
tab.url;
|
tab.url;
|
||||||
|
|
||||||
let mealie_url = url;
|
let mealie = 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 group_slug = "" // Change this to your group slug. You can obtain this from your URL after logging-in to Mealie
|
// 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 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
|
// 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
|
// Open a new tab with the destination URL
|
||||||
browser.tabs.create({ url: dest }).then(() => {
|
browser.tabs.create({ url: dest }).then(() => {
|
||||||
console.log(`New tab opened with URL: ${dest}`);
|
console.log(`New tab opened with URL: ${dest}`);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
console.error("Error opening new tab:", error);
|
console.error("Error opening new tab:", error);
|
||||||
});
|
});
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Submit POST request to your Mealie server
|
// Submit POST request
|
||||||
const postUrl = `${mealie_url}/api/recipes/create/url`;
|
const postUrl = `${mealie}/api/recipes/create/url`;
|
||||||
const requestBody = {
|
const requestBody = {
|
||||||
includeTags: false,
|
includeTags: true,
|
||||||
url: site_url
|
url: site_url
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +79,9 @@ browser.contextMenus.create({
|
||||||
|
|
||||||
// Add a listener for the context menu item
|
// Add a listener for the context menu item
|
||||||
browser.contextMenus.onClicked.addListener((info, tab) => {
|
browser.contextMenus.onClicked.addListener((info, tab) => {
|
||||||
|
console.log("click 1");
|
||||||
if (info.menuItemId === "clickHere") {
|
if (info.menuItemId === "clickHere") {
|
||||||
|
console.log("click 2");
|
||||||
Clicked();
|
Clicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
7
extension/content.js
Normal file
7
extension/content.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
// content.js
|
||||||
|
|
||||||
|
console.log("Content.js is loaded");
|
||||||
|
|
||||||
|
browser.runtime.onMessage.addListener((message) => {
|
||||||
|
console.log(`Received message: ${message}`);
|
||||||
|
});
|
|
@ -30,5 +30,11 @@
|
||||||
"options_ui": {
|
"options_ui": {
|
||||||
"page": "options.html",
|
"page": "options.html",
|
||||||
"open_in_tab": true
|
"open_in_tab": true
|
||||||
}
|
},
|
||||||
|
"content_scripts": [
|
||||||
|
{
|
||||||
|
"matches": ["<all_urls>"],
|
||||||
|
"js": ["content.js"]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
Loading…
Reference in a new issue