Embed tweets from url

I often put twitter urls in my inbox and then forget what it was about. Instead of having to open each URL separately, I wrote a little tampermonkey script that embeds the tweet.

// ==UserScript==
// @name         Dynalist Tweet preview
// @namespace    http://louiskirsch.com/
// @version      0.1
// @description  Resolves twitter links and displays them as tweets inline
// @author       Louis Kirsch
// @match        https://dynalist.io/d/*
// @grant        GM.xmlHttpRequest
// @run-at       document-idle
// @require      https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==

var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://platform.twitter.com/widgets.js";
s.async = true;

waitForKeyElements("a.node-link[href^='https://twitter.com/", actionFunction, false);

function actionFunction(links) {
    links.each((i, l) => {
        var requestUrl = 'https://publish.twitter.com/oembed?omit_script=1&url=' + l.href;
            method: "GET",
            url: requestUrl,
            onload: function(response) {
                var data = JSON.parse(response.responseText);
                if (twttr.widgets != undefined) {

This is welcome. I note this has been possible in Roam. When I install the script, it get the plain text from the Twitter post, but not the formatting as in yours. There may be a clash with CSS.

1 Like

I am not entirely sure now what you meant. Roam embeds tweets by default or you run my script in Roam?

in Dynalist?

So this is a tweet in Twitter:

And how it appears when the link is copied into Dynalist with your script.

It’s still useful, but not embedded.

Hum okay, that’s odd. Are there any errors in the console?

I’m not sure if it is relevant, but this is the error message:

Refused to load the font ‘’ because it violates the following Content Security Policy directive: “default-src *”. Note that ‘font-src’ was not explicitly set, so ‘default-src’ is used as a fallback

Hey @Louis_Kirsch, I tried your script but it doesn’t seem to work (I’m on Firefox). I got error messages on lines 19, 29, 30 :

  • eslint : no undef - waitforkeyelements is not defined
  • eslint : no undef - ‘$’ is not defined
  • eslint : no undef - ‘twttr is nor defined’