mirror of
https://github.com/arfct/itty-bitty.git
synced 2026-03-11 08:54:33 +00:00
Add clientside dom parsers
This commit is contained in:
parent
0afa3d64dc
commit
97a7c4daac
2 changed files with 10 additions and 0 deletions
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
const renderers = {
|
||||
"application/ld+json": {script:"recipe"},
|
||||
"text/rawhtml": {script:"parse"},
|
||||
"javascript": {script:"bookmarklet"},
|
||||
"web3": {script:"web3", mode:"frame"},
|
||||
}
|
||||
|
|
|
|||
9
docs/render/parse.js
Normal file
9
docs/render/parse.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// let title = params.title
|
||||
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(params.body, "text/html");
|
||||
|
||||
let ldjson = doc.querySelector('script[type="application/ld+json"]').innerText.trim();
|
||||
let f = new FileReader();
|
||||
f.onload = function(e) { top.location.href = ( '/#/' + e.target.result);};
|
||||
f.readAsDataURL(new Blob([ldjson],{type : 'application/ld+json;charset=utf-8'}));
|
||||
Loading…
Reference in a new issue