diff options
author | makc | 2020-02-02 13:44:24 +0200 |
---|---|---|
committer | makc | 2020-02-02 13:44:24 +0200 |
commit | 23aba1cc93d1ee28a52560b2205a992494d04a33 (patch) | |
tree | e301875983d0684bc3f665950438229e454b5b41 /src/main | |
parent | 496cb3eb32cc20dbb8e77f81067162db61e20312 (diff) |
fix twitter embed
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/assets/embed.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main/assets/embed.js b/src/main/assets/embed.js index 6cb02110..6498971c 100644 --- a/src/main/assets/embed.js +++ b/src/main/assets/embed.js @@ -254,14 +254,15 @@ function getEmbeddableLinkTypes() { 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 { + } 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'; - div.appendChild(script); + document.head.appendChild(script); } return div; |