Embed Tweets in an iframe - https://tf.rita.moe
1<!doctype html> 2<html lang="en"> 3<head> 4<style type="text/css"> 5 #author_name { 6 font-weight: bold; 7 } 8 body { 9 padding-top: 1px; 10 } 11 #brand { 12 background-color: #fbfbfb; 13 color: #bbb; 14 font-family: helvetica neue, arial, sans-serif; 15 font-size: 8pt; 16 left: 0px; 17 padding-left: 0.5em; 18 padding-right: 0.5em; 19 position: absolute; 20 top: 0px; 21 } 22 #brand a { 23 color: #aaa; 24 text-decoration: none; 25 } 26</style> 27</head> 28<body> 29 <span id="brand"> 30 <a href="https://twitframe.com/?ref=t" target="_blank">Twitframe</a> 31 </span> 32 <blockquote class="twitter-tweet" id="t"> 33 <span id="author_name"></span> 34 <span id="author_username"></span> 35 <p> 36 <span id="tweet"></span> 37 </p> 38 <a id="date"></a> 39 </blockquote> 40</body> 41<script> 42 43var params = {}; 44location.search.substr(1).split("&").forEach(function(part) { 45 var item = part.split("="); 46 params[item[0]] = decodeURIComponent(item[1]).replace(/\+/g, " "); 47}); 48 49var url = params["url"] || ""; 50var datetime = (params["datetime"] || 0); 51var tweet = (params["tweet"] ? params["tweet"] : "Loading tweet..."); 52var author_name = (params["author_name"] ? params["author_name"] : ""); 53var author_username = (params["author_username"] ? params["author_username"] : ""); 54var align = params["align"]; 55var link_color = params["link_color"]; 56var theme = params["theme"]; 57var formatted_date = "Unknown date"; 58 59var m; 60if (m = url.match(/^(https?:)?\/\/(www\.)?twitter\.com\/([^\/]+)\//)) { 61 if (!author_username) 62 author_username = m[3]; 63} 64 65if (author_username && author_username.substr(0, 1) != "@") 66 author_username = "@" + author_username; 67 68if (datetime) { 69 var d = new Date(datetime * 1000); 70 formatted_date = d.toDateString(); 71} 72 73var t = document.getElementById("t"); 74if (align) 75 t.align = align; 76if (link_color) 77 t.data["link-color"] = link_color; 78if (theme) 79 t.data["theme"] = theme; 80 81var h = ""; 82if (author_name) 83 document.getElementById("author_name").innerText = author_name; 84if (author_username) 85 document.getElementById("author_username").innerText = author_username; 86 87document.getElementById("tweet").innerText = tweet; 88 89document.getElementById("date").href = url; 90document.getElementById("date").innerText = formatted_date; 91 92if (!params["force_fail"]) { 93 var s = document.createElement("script"); 94 s.src = "https://platform.twitter.com/widgets.js"; 95 document.body.appendChild(s); 96} 97 98var caller, _timer, loaded = false; 99var saveCaller = function(e) { 100 if (e.data.element) { 101 caller = e; 102 if (loaded) 103 sendResponse(); 104 } 105}; 106if (window.addEventListener) 107 window.addEventListener("message", saveCaller, false); 108else 109 window.attachEvent("onmessage", saveCaller); 110 111function onload() { 112 if (arguments.callee.done) 113 return; 114 arguments.callee.done = true; 115 116 if (_timer) 117 clearInterval(_timer); 118 119 loaded = true; 120 if (caller) 121 sendResponse(); 122} 123 124if (document.addEventListener) 125 document.addEventListener("DOMContentLoaded", onload, false); 126else if (/WebKit/i.test(navigator.userAgent)) { 127 _timer = setInterval(function() { 128 if (/loaded|complete/.test(document.readyState)) 129 onload(); 130 }, 10); 131} 132else 133 window.onload = onload; 134 135function sendResponse() { 136 if (caller.data.query == "height") { 137 setTimeout(function() { 138 caller.source.postMessage({ element: caller.data.element, 139 height: document.body.scrollHeight + 20 }, caller.origin); 140 }, 500); 141 } 142}; 143</script> 144</html>