Skip to content

Instantly share code, notes, and snippets.

@scotu
Created June 19, 2014 17:51
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 scotu/49406460d090dbb56a03 to your computer and use it in GitHub Desktop.
Save scotu/49406460d090dbb56a03 to your computer and use it in GitHub Desktop.
Friendfeed fixed bookmarklet code
(function(){function A(){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+s+"px",a.style.height=k+s+"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<t||f.height<t)){c++;var l=q(f,"mouseover",u(B,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";C(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=v);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);"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("&")));w(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(){D();a()},50);a();window.onscroll=function(){g.style.top=p().y+"px"}}}function B(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 "+E;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",u(F,a));q(e,"mouseout",G);c.style.display="";n(b)}function G(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 F(a,b){n(b);"http://l.yimg.com/g/images/spaceball.gif"==a.src&&(a=a.previousSibling);w({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 H(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 x(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 y(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 u(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 C(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 w(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 D(){var a=location.href.split("#")[1];if(a&&"FFSHARE-"==a.substring(0,8)){location.replace(location.href.split("#")[0]+"#");v(a);var b=z;x(b);setTimeout(function(){x(b)},10)}else z=p()}function v(a){a=a.split("-");for(var b=0;b<a.length;b++)a[b]=decodeURIComponent(a[b]);switch(a[1]){case "close":I(a.slice(2));break;case "frameh":document.getElementById("ff__foreground").style.height=a[2]+"px"}}function I(a){function b(){y(document.getElementById("ff__container"));
return!1}window.ff_reshare&&delete window.ff__reshare;window.onscroll=null;for(var c=0;c<r.length;c++)H(r[c].listener);y(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 t=30,E="#1030cc",k=3,s=7,r=[],z=p();0==document.getElementsByTagName("head").length||frames.length>document.getElementsByTagName("iframe").length?window.location.href="http://friendfeed.com/?link="+escape(window.location.href):A()})();
@scotu
Copy link
Author

scotu commented Jun 19, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment