Update parse and share

This commit is contained in:
Nicholas Jitkoff 2023-02-11 09:32:28 -07:00
parent a6fbef9efe
commit 992a2ff62b
2 changed files with 11 additions and 5 deletions

View file

@ -35,6 +35,10 @@ function findMicrodataRecipe(doc) {
}
let textRecipe = async document => {
console.log("text recipe", document, document.documentElement.textContent)
return {};
}
let scrapeRecipe = async document => {
@ -121,13 +125,13 @@ let scrapeRecipe = async document => {
console.warn("Extracted", JSON.stringify(recipe,undefined,2))
// return undefined
if (!recipe.recipeInstructions) return undefined
return recipe;
}
let recipe = findLDJsonRecipe(doc) || findMicrodataRecipe(doc) || await scrapeRecipe(doc);
let recipe = findLDJsonRecipe(doc) || findMicrodataRecipe(doc) || await scrapeRecipe(doc) || await textRecipe(doc);
if (!recipe.recipeInstructions) recipe = undefined;

View file

@ -412,8 +412,10 @@ function startTimer(e, t1, t2) {
window.startTimer = startTimer;
function share() {
parent.postMessage({share:{}}, "*");
function share(e) {
var viewportOffset = e.target.getBoundingClientRect();
console.log(e, viewportOffset)
parent.postMessage({share:{clientX:e.clientX, clientY:e.clientY, offset:viewportOffset}}, "*");
}
function faviconForTitle(title) {
@ -669,7 +671,7 @@ function render() {
),
m(".actions.print-hide.watch-hide",
// originalURL ? m("a.action", { title:"Open original", href: originalURL, target:"_blank"}, m(".icon.public", {innerHTML:icons.public})) : null,
navigator.share ? m("a.action", { title:"Share", onclick: share}, m(".icon.share", {innerHTML:icons.share})) : undefined,
m("a.action", { title:"Share", onclick: share}, m(".icon.share", {innerHTML:icons.share})),
// m("a.action", { title:"Show steps as list", onclick: () => {reformat = !reformat; render(); return false;}}, m(".icon.checklist")),
m("a.action", { title:"Print", onclick: () => {window.print(); return false;} }, m(".icon.print", {innerHTML:icons.print})),
)