Skip to content

Instantly share code, notes, and snippets.

@wittman
Last active August 29, 2015 14:02
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 wittman/861b7b7fc0bc391f48f0 to your computer and use it in GitHub Desktop.
Save wittman/861b7b7fc0bc391f48f0 to your computer and use it in GitHub Desktop.
(function(){function C(){function a(){var a=document.getElementById("ff__shadow"),b=document.getElementById("ff__foreground");if(!a||!b)clearInterval(n);else if(h!=b.offsetWidth||k!=b.offsetHeight)h=b.offsetWidth,k=b.offsetHeight,a.style.width=h+u+"px",a.style.height=k+u+"px"}if(!document.getElementById("ff__container")){var b;window.getSelection?b=""+window.getSelection():document.selection&&(b=document.selection.createRange().text);for(var c=0,e=window.ff__reshare?[]:document.getElementsByTagName("img"),
d=0;d<e.length;d++){var f=e[d];if(!(f.width<v||f.height<v)){c++;var l=q(f,"mouseover",w(D,f));r.push({element:f,cursor:f.style.cursor,listener:l})}}var g=m();g.id="ff__container";g.style.position="absolute";g.style.top=p().y+"px";g.style.right="0";g.style.width="auto";g.style.zIndex=1E5;d=m(g);d.id="ff__shadow";d.style.backgroundColor="black";d.style.position="absolute";d.style.zIndex=0;d.style.top="0";d.style.right="0";E(d,.3);d=m(g);d.id="ff__foreground";d.style.backgroundColor="white";d.style.zIndex=
2;d.style.width="450px";d.style.height="310px";d.innerHTML='<iframe frameborder="0" id="ff__iframe" style="width:100%;height:100%;border:0px;padding:0px;margin:0px"></iframe>';document.body.appendChild(g);c={title:document.title,url:location.href,parenturl:location.href};window.ff__reshare&&(c={reshare:"1"},window.handleShareMessage=x);c.selection=b||"";b=document.getElementsByTagName("link");for(d=0;d<b.length;d++)"image_src"==b[d].rel?c.image=b[d].href:"video_src"==b[d].rel&&(c.video=b[d].href);
b=document.getElementsByTagName("meta");for(d=0;d<b.length;d++)"video_thumb"==b[d].name&&(c.image=b[d].content);-1<location.href.indexOf("https://www.youtube.com/")&&(b=s('meta[property="og:image"]'),1==b.length&&(c.image=b[0].content));"www.theonion.com"==location.host&&"undefined"!=typeof player&&"undefined"!=typeof player.playlist&&(c.video=player.playlist);c.image&&-1!=c.image.indexOf("http://www.comedycentral.com/sitewide/droplets/img_rez.jhtml")&&(c.image="http://www.comedycentral.com"+c.image.slice(c.image.indexOf("/",
c.image.indexOf("?")),c.image.indexOf("&")));t(c);b=m();b.id="ff__popup";b.style.position="absolute";b.style.display="none";b.style.left="0px";b.style.top="0px";b.style.zIndex=99999;b.style.fontSize="8pt";b.style.fontFamily="Arial";b.style.fontStyle="normal";b.style.fontWeight="normal";b.style.background="transparent";document.body.appendChild(b);var h=0,k=0,n=window.setInterval(function(){F();a()},50);a();window.onscroll=function(){g.style.top=p().y+"px"};"www.flickr.com"==location.host&&(b=s(".main-photo"),
1==b.length&&y(b));-1<location.host.indexOf("woot.com")&&(b=s(".photo.current img"),1==b.length&&y(b))}}function D(a,b){var c=document.getElementById("ff__popup");c.style.display="none";h(c);var e=m(c);e.style.position="absolute";var d=a,f=0,l=0;if(d.offsetParent)for(f=d.offsetLeft,l=d.offsetTop;d=d.offsetParent;)f+=d.offsetLeft,l+=d.offsetTop;e.style.left=f-k+1+"px";e.style.top=l-k+1+"px";e.style.width=a.width+"px";e.style.height=a.height+"px";e.style.border=k+"px solid "+G;e.style.cursor="pointer";
e.innerHTML='<div style="margin:0;padding:0;width:100%;height:100%;position:relative;z-index:1;background-color:white;filter:alpha(opacity=1);opacity: 0.01"></div><div style="margin:0;position:absolute;top:0;left:0;background-color:white;padding:3px;color:#1030cc;border: 1px solid #1030cc;border-width: 0px 1px 1px 0px;z-index:2">Share image on FriendFeed</div>';q(e,"click",w(H,a));q(e,"mouseout",I);c.style.display="";n(b)}function I(a){var b=document.getElementById("ff__popup");if(b){for(var c=a.toElement||
a.relatedTarget;c;c=c.parentNode)if(c==b)return;h(b);b.style.display="none";n(a)}}function H(a,b){n(b);"http://l.yimg.com/g/images/spaceball.gif"==a.src&&(a=a.previousSibling);t({image:a.src,w:a.width,h:a.height})}function q(a,b,c){var e=c;if(a.addEventListener)a.addEventListener(b,e,!1);else if(a.attachEvent)e=function(){c(window.event)},a.attachEvent("on"+b,e);else throw Error("Event registration not supported");return{instance:a,name:b,listener:e}}function J(a){var b=a.instance;b.removeEventListener?
b.removeEventListener(a.name,a.listener,!1):b.detachEvent&&b.detachEvent("on"+a.name,a.listener)}function n(a){a||(a=window.event);a.preventDefault?a.preventDefault():a.returnValue=!1}function p(){if(void 0!==self.pageYOffset)return{x:self.pageXOffset,y:self.pageYOffset};var a=document.documentElement;return{x:a.scrollLeft,y:a.scrollTop}}function z(a){var b=document.documentElement,c=document.body;b.scrollLeft=c.scrollLeft=a.x;b.scrollTop=c.scrollTop=a.y}function h(a){for(;a.firstChild;)a.removeChild(a.firstChild)}
function A(a){a&&a.parentNode&&a.parentNode.removeChild(a)}function m(a){var b=document.createElement("div");b.style.padding="0";b.style.margin="0";b.style.border="0";b.style.position="relative";a&&a.appendChild(b);return b}function w(a){for(var b=[],c=1;c<arguments.length;c++)b.push(arguments[c]);return function(){for(var c=[],d=0;d<b.length;d++)c.push(b[d]);for(d=0;d<arguments.length;d++)c.push(arguments[d]);return a.apply(null,c)}}function s(a){return"function"===typeof document.querySelectorAll?
document.querySelectorAll(a):[]}function y(a){1==a.length&&setTimeout(function(){t({image:a[0].src,w:a[0].width,h:a[0].height})},2E3)}function E(a,b){if(-1!=navigator.userAgent.indexOf("MSIE")){var c=Math.round(100*b);a.style.filter="alpha(opacity="+c+")"}else a.style.opacity=b}function t(a){var b="",c;for(c in a)a.hasOwnProperty(c)&&(b+=b.length?"&":"",b+=encodeURIComponent(c)+"="+encodeURIComponent(a[c]));if(a=-1!=navigator.userAgent.indexOf("Safari")?frames.ff__iframe:document.getElementById("ff__iframe").contentWindow){c=
window.ff__reshare?"":"https://friendfeed.com";c+="/share/bookmarklet/frame#"+b;try{a.location.replace(c)}catch(e){a.src=c}}}function F(){var a=location.href.split("#")[1];if(a&&"FFSHARE-"==a.substring(0,8)){location.replace(location.href.split("#")[0]+"#");x(a);var b=B;z(b);setTimeout(function(){z(b)},10)}else B=p()}function x(a){a=a.split("-");for(var b=0;b<a.length;b++)a[b]=decodeURIComponent(a[b]);switch(a[1]){case "close":K(a.slice(2));break;case "frameh":document.getElementById("ff__foreground").style.height=
a[2]+"px"}}function K(a){function b(){A(document.getElementById("ff__container"));return!1}window.ff_reshare&&delete window.ff__reshare;window.onscroll=null;for(var c=0;c<r.length;c++)J(r[c].listener);A(document.getElementById("ff__popup"));a&&a.length?(a=a[0].replace("<a ",'<a style="font-weight:bold;color:#1030cc" '),c=document.getElementById("ff__foreground"),h(c),c.style.color="black",c.style.padding="4px 10px 4px 4px",c.style.font="10pt Arial, sans-serif",c.style.fontStyle="normal",c.style.fontWeight=
"normal",c.style.width="",c.style.height="",c.innerHTML='<img style="width:16px;height:16px;margin-bottom:-3px;margin-right:1px" src="http://friendfeed.com/static/images/icons/internal.png?v=e471e9afdf04ae568dcbddb5584fc6c0"> '+a+' <a href="#" id="ff__close" style="margin-left:1em;color:#1030cc">close</a>',document.getElementById("ff__close").onclick=b,setTimeout(b,3500)):b()}var v=30,G="#1030cc",k=3,u=7,r=[],B=p();0==document.getElementsByTagName("head").length||frames.length>document.getElementsByTagName("iframe").length?
window.location.href="http://friendfeed.com/?link="+escape(window.location.href):C()})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment