mirror of
https://github.com/arfct/itty-bitty.git
synced 2026-03-11 08:54:33 +00:00
Updated bookmarklet
This commit is contained in:
parent
42b1193bfa
commit
d7b3da1cf7
7 changed files with 27 additions and 23 deletions
|
|
@ -1,4 +1 @@
|
|||
body{margin:0 auto;padding:12vmin 10vmin;max-width:35em;line-height:1.5em;font-family:-apple-system,BlinkMacSystemFont,sans-serif;word-wrap:break-word;}
|
||||
|
||||
|
||||
@media (prefers-color-scheme: dark){body{color:white;background-color:#111;}}
|
||||
body{margin:0 auto;padding:12vmin 10vmin;max-width:35em;line-height:1.5em;font-family:-apple-system,BlinkMacSystemFont,sans-serif;word-wrap:break-word;}@media(prefers-color-scheme: dark){body{color:white;background-color:#111;}}
|
||||
|
|
@ -15,9 +15,9 @@ https://itty.bitty.app/Recipe_Bookmarklet/Simplify_recipes_with_a_click./%F0%9F%
|
|||
|
||||
// DOM extraction
|
||||
|
||||
javascript:f=new FileReader();f.onload=function(e){top.location.href=('https://itty.bitty.app/#/'+e.target.result)};f.readAsDataURL(new Blob([document.documentElement.outerHTML],{type:'text/raw+html;render=parse;encode=none;charset=utf-8'}));
|
||||
javascript:f=new(FileReader)();f.onload=function(e){top.location.href=('https://itty.bitty.app/#/'+e.target.result)};f.readAsDataURL(new(Blob)([document.documentElement.outerHTML],{type:'text/raw+html;render=parse;encode=none;charset=utf-8'}));
|
||||
|
||||
javascript:f=new FileReader();f.onload=function(e){top.location.href=('http://localhost:8888/#/'+e.target.result)};f.readAsDataURL(new Blob([document.documentElement.outerHTML],{type:'text/raw+html;render=parse;encode=none;charset=utf-8'}));
|
||||
javascript:f=new(FileReader)();f.onload=function(e){top.location.href=('http://localhost:8888/#/'+e.target.result)};f.readAsDataURL(new(Blob)([document.documentElement.outerHTML],{type:'text/raw+html;render=parse;encode=none;charset=utf-8'}));
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,5 @@
|
|||
<script src="/index.js" type="module"></script>
|
||||
<script nomodule> // Use V1 renderer </script>
|
||||
<noscript>itty.bitty requires JavaScript.</noscript>
|
||||
<div id="toast">
|
||||
itty.bitty is experimental technology that renders linked content from outside sources.
|
||||
<a href="http://toast.bitty.site" target="_blank">Learn more</a>.
|
||||
<br><br>This content is only as trustworthy as its source, and it should be treated with the caution you would show any insecure web page.
|
||||
<br><br><button onclick="dismiss()">I understand</button> <input id="never" type="checkbox"><label for="never">Never show this</label>
|
||||
</div>
|
||||
<iframe id="iframe" sandbox="allow-downloads allow-scripts allow-forms allow-top-navigation allow-popups allow-modals allow-popups-to-escape-sandbox"></iframe>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,15 @@
|
|||
if (document.getElementById("never").checked) window.localStorage.setItem('toasted', true);
|
||||
document.body.classList.remove("toasting")
|
||||
}
|
||||
|
||||
function addToast() {
|
||||
// `<div id="toast">
|
||||
// itty.bitty is experimental technology that renders linked content from outside sources.
|
||||
// <a href="http://toast.bitty.site" target="_blank">Learn more</a>.
|
||||
// <br><br>This content is only as trustworthy as its source, and it should be treated with the caution you would show any insecure web page.
|
||||
// <br><br><button onclick="dismiss()">I understand</button> <input id="never" type="checkbox"><label for="never">Never show this</label>
|
||||
// </div>`
|
||||
}
|
||||
|
||||
function setFavicon(favicon) {
|
||||
document.getElementById("favicon").href = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"><text y=".9em">'+ favicon + '</text></svg>'
|
||||
|
|
@ -75,17 +84,16 @@
|
|||
var dataPrefix = undefined;
|
||||
var renderMode = "data";
|
||||
|
||||
|
||||
let components = window.location.pathname.substring(1).split("/");
|
||||
let info = {}
|
||||
info.t = decodeURIComponent(components.shift()).replace(/_/g, " ");
|
||||
components.forEach(component => {
|
||||
let field = component.split(":");
|
||||
let key = field.shift();
|
||||
let value = decodeURIComponent(field.join(":"));
|
||||
info.title = decodeURIComponent(components.shift()).replace(/-/g, " ").replace(/–/g, "-");
|
||||
let i;
|
||||
for (i = 0; i < components.length; i+=2) {
|
||||
let key = components[i];
|
||||
let value = decodeURIComponent(components[i+1]);
|
||||
if (key.length && value.length) info[key] = value;
|
||||
})
|
||||
info.d = info.d?.replace(/_/g, " ");
|
||||
}
|
||||
info.d = info.d?.replace(/-/g, " ").replace(/–/g, "-");
|
||||
|
||||
|
||||
var slashIndex = fragment.indexOf("/");
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ a.bookmarklet {
|
|||
transition:transform 1s;
|
||||
}
|
||||
|
||||
.description {
|
||||
opacity:0.2;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
.hint {
|
||||
font-size:small;
|
||||
opacity:0.54;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ loadSyle(document.currentScript.src.replace("js", "css"))
|
|||
|
||||
document.body.appendChild(
|
||||
el("div", {id:"content"},
|
||||
el("a", {className:"bookmarklet", href:url}, el("span", {className:"capsule", innerText:"▶ " + title || "Bookmarklet"})),
|
||||
el("p", {id:"emoji", innerText:"☝️"}),
|
||||
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 <a target="_blank" href="https://en.wikipedia.org/wiki/Bookmarklet">bookmarklet</a>.`}),
|
||||
|
||||
el("p", {className:"", innerText:`Drag this bookmarklet to your ${managerName} to use it.`}),
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ if (ldjson) {
|
|||
let f = new FileReader();
|
||||
f.onload = function(e) {
|
||||
//top.location.href = ( '/#/' + e.target.result);
|
||||
parent.postMessage({replaceURL:'/temp#/' + e.target.result}, "*");
|
||||
parent.postMessage({replaceURL:'/#/' + e.target.result}, "*");
|
||||
};
|
||||
f.readAsDataURL(new Blob([ldjson],{type : 'application/ld+json;charset=utf-8'}));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue