diff options
Diffstat (limited to 'src/main/assets')
-rw-r--r-- | src/main/assets/embed.js | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/main/assets/embed.js b/src/main/assets/embed.js index 0022ae82..5e5d1fee 100644 --- a/src/main/assets/embed.js +++ b/src/main/assets/embed.js @@ -1,4 +1,3 @@ - function insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } @@ -250,23 +249,11 @@ function getEmbeddableLinkTypes() { ctsDefault: false, re: /^(?:https?:)?\/\/(?:www\.)?(?:mobile\.)?twitter\.com\/([\w-]+)\/status(?:es)?\/([\d]+)/i, makeNode: function(aNode, reResult, div) { - let [url, userId, postId] = reResult; - url = url.replace('mobile.', ''); - - div.innerHTML = `<blockquote class="twitter-tweet" data-lang="en"><a href="${url}"></a></blockquote>`; - - if (window['twttr']) { - // this will only happen if you embed another set of twitter posts after the twitter script loads (likely never) - // https://developer.twitter.com/en/docs/twitter-for-websites/javascript-api/guides/scripting-loading-and-initialization - window['twttr'].widgets.load(div); - } else if (!document.head.querySelector ('[src="https://platform.twitter.com/widgets.js\"]')) { - // innerHTML cannot insert scripts, so... - let script = document.createElement('script'); - script.src = 'https://platform.twitter.com/widgets.js'; - script.charset = 'utf-8'; - document.head.appendChild(script); - } - + fetch('https://juick.com/srv/oembed?url=' + reResult[0]) + .then(response => response.json()) + .then(json => { + div.innerHTML = json.html; + }); return div; } }, |