Hide bookmarklet loader

This commit is contained in:
Nicholas Jitkoff 2022-12-04 10:03:29 -08:00
parent ffda6ea2b3
commit 63698da413
2 changed files with 6 additions and 2 deletions

View file

@ -20,7 +20,7 @@ loadSyle(script.replace("js", "css")).then(() => {
el("div", {className:"description"}, params.info?.d ?? ""),
el("a", {className:"bookmarklet", href:url}, el("span", {className:"capsule", innerText:"" + title || "Bookmarklet"})),
el("p", {id:"emoji", innerText:"☝️"}),
el("p", {innerHTML:`This page contains a bookmarklet. (<a target="_blank" href="https://en.wikipedia.org/wiki/Bookmarklet">learn more</a>)`}),
el("p", {innerHTML:`This page contains a bookmarklet.<br>(<a target="_blank" href="https://en.wikipedia.org/wiki/Bookmarklet">learn more</a>)`}),
el("p", {className:"", innerText:`Drag this bookmarklet to your ${managerName} to use it.`}),
el("p", {className:"hint desktop", innerText:`(Hit ${cmdKey} to toggle the ${managerName} bar)`}),
@ -29,4 +29,6 @@ loadSyle(script.replace("js", "css")).then(() => {
)
);
parent.postMessage({}, "*");
})

View file

@ -10,10 +10,12 @@
.pop();
if (!ld) alert("No recipe data found on this page. Sorry!");
ld = JSON.parse(ld);
if (ld["@type"] != "Recipe"){ ld=(ld["@graph"]??ld).find((item)=>item["@type"]=="Recipe") }
if (Array.isArray(ld)) ld = ld.pop();
if (!ld["@type"]?.includes("Recipe")){ ld=(ld["@graph"]??ld).find((item)=>item["@type"]=="Recipe") }
delete ld.review;
delete ld.video;
if (!ld.url) ld.url = location.href;
console.log("Found Recipe", ld)
f = new FileReader();
f.onload = function(e) {location.href=(ib + '/#/' + e.target.result);};
f.readAsDataURL(new Blob([JSON.stringify(ld)],{type:'application/ld+json;compress=true;charset=utf-8'}));