Skip to content

Instantly share code, notes, and snippets.

@nabettu
Created January 31, 2016 20:42
Show Gist options
  • Save nabettu/dc7467f0dfaf0a57d761 to your computer and use it in GitHub Desktop.
Save nabettu/dc7467f0dfaf0a57d761 to your computer and use it in GitHub Desktop.
javascript: (function() {
javascript: (function(d, j, b, s) {
function r() {
setTimeout(function() {
(typeof jQuery == 'undefined') ? r(): b(jQuery)
}, 99)
}(j) ? b(jQuery): d.body.appendChild(d.createElement('script')).src = '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', r()
})(document, this.jQuery, function($) {
var ogurl = $("meta[property='og:url']").attr("content");
var ogtitle = $("meta[property='og:title']").attr("content");
var ogdesc = $("meta[property='og:description']").attr("content");
var ogimg = $("meta[property='og:image']:last").attr("content");
var urlhost = location.host;
if (ogtitle == null) {
ogtitle = document.title
};
if (ogurl == null) {
ogurl = location.href
};
if (ogdesc == null) {
ogdesc = ""
};
if (ogimg == null) {
ogimg = "http://capture.heartrails.com/100x100/?" + location.href
};
var card = '<!--' + ogtitle + '--><div style="width:100%;max-width:500px;margin:0 0 20px 0;background:#fff;border:1px solid#ccc;border-radius:5px;box-sizing:border-box;padding:12px;"><div style="width:100px;height:100px;float:right;margin:0 0 10px 10px;padding:0;position:relative;overflow:hidden;"><a href="' + ogurl + '"style="position:absolute;width:1000%;left:50%;margin:0 0 0 -500%;text-align:center;"><img src="' + ogimg + '"style="width:auto;height:100px;margin:0;vertical-align:middle;display:inline;"></a></div><p style="margin:0;"><a href="' + ogurl + '"style="color:#333;font-weight:bold;text-decoration:none;font-size:17px;margin:0 0 10px 0;line-height:1.5;">' + ogtitle + '</a></p><p style="margin:0;color:#666;font-size:11px;line-height:1.5;">' + ogdesc + '</p><div style="border-top:1px solid#eee;clear:both;margin:10px 0 0 0;padding:0;"><p style="color:#999;margin:3px 0 0 0;font-size:11px;"><img src="http://favicon.hatena.ne.jp/?url=' + ogurl + '"style="margin:0 5px 0 0;padding:0;border:none;display:inline;vertical-align:middle;">' + urlhost + '<img src="http://b.hatena.ne.jp/entry/image/' + ogurl + '"style="margin:0 0 0 5px;padding:0;border:none;display:inline;vertical-align:middle;"></p></div></div>';
prompt("blogcard", card);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment