Skip to content

Instantly share code, notes, and snippets.

@pbausch
Created November 10, 2016 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbausch/d37a2d1720bce8533d1e6749d2352d98 to your computer and use it in GitHub Desktop.
Save pbausch/d37a2d1720bce8533d1e6749d2352d98 to your computer and use it in GitHub Desktop.
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