aboutsummaryrefslogtreecommitdiff
path: root/src/main/assets/embed.js
diff options
context:
space:
mode:
authorGravatar makc2020-02-02 13:44:24 +0200
committerGravatar makc2020-02-02 13:44:24 +0200
commit23aba1cc93d1ee28a52560b2205a992494d04a33 (patch)
treee301875983d0684bc3f665950438229e454b5b41 /src/main/assets/embed.js
parent496cb3eb32cc20dbb8e77f81067162db61e20312 (diff)
fix twitter embed
Diffstat (limited to 'src/main/assets/embed.js')
-rw-r--r--src/main/assets/embed.js5
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;