Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Embed Tweets on the Belong.io Page with Tampermonkey
// ==UserScript==
// @name Belong Tweets
// @namespace http://tampermonkey.net/
// @version 0.1
// @description add embedded via tweets
// @author @pbausch
// @match http://belong.io/
// @grant none
// ==/UserScript==
(function() {
'use strict';
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://platform.twitter.com/widgets.js";
s.async = true;
document.head.append(s);
setTimeout(function(){
var bookmarks = document.getElementsByClassName("item-via");
var tweets = new Array();
for(var i = 0; i < bookmarks.length; i++) {
var burl = bookmarks[i].childNodes[0].getAttribute("href");
var re = new RegExp("status\/(\\d{15,20})");
var e = re.exec(burl);
if (e !== null) {
bookmarks[i].childNodes[0].innerHTML += '<div id="t'+ e[1] +'" tweetID="'+ e[1] +'" style="width:500px;"></div>';
var id = e[1];
var tweet = document.getElementById('t'+id);
if (!tweets.includes(e[1])) {
twttr.widgets.createTweet(
id, tweet,
{
conversation : 'none', // or all
cards : 'visible', // or visible
linkColor : '#cc0000', // default is blue
theme : 'light' // or dark
});
}
tweets.push(e[1]);
}
}
}, 500);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment