From e5a7fa02be0f56f034ffaf3bca7fdb523d3ef90f Mon Sep 17 00:00:00 2001 From: Federico Date: Wed, 6 Jan 2021 15:19:41 -0600 Subject: Fix `embed-gist-inline` style and preserve the original link (#3866) --- source/features/embed-gist-inline.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source/features/embed-gist-inline.tsx') diff --git a/source/features/embed-gist-inline.tsx b/source/features/embed-gist-inline.tsx index 10b9c203..13fc2022 100644 --- a/source/features/embed-gist-inline.tsx +++ b/source/features/embed-gist-inline.tsx @@ -19,16 +19,15 @@ async function embedGist(link: HTMLAnchorElement): Promise { link.after(info); try { - // Get the gist via background.js due to CORB policies introduced in Chrome 73 - const gistData = await browser.runtime.sendMessage({request: `${link.href}.json`}); - - const files = domify.one(JSON.parse(gistData).div)!; - const fileCount = files.children.length; + // Fetch via background.js due to CORB policies + const gistData = await browser.runtime.sendMessage({fetchJSON: `${link.href}.json`}); + const fileCount: number = gistData.files.length; if (fileCount > 1) { info.textContent = ` (${fileCount} files)`; } else { - link.parentElement!.attachShadow({mode: 'open'}).append( + const container =
; + container.attachShadow({mode: 'open'}).append( , , - files + domify.one(gistData.div)! ); + link.parentElement!.after(container); + info.remove(); } } catch { info.remove(); -- cgit v1.2.3