WordPress/wp-admin/js/bookmarklet.min.js

1 line
2.3 KiB
JavaScript

(function(t,i,e,a){var n,o,l,m,r,s,c,h,d=t.encodeURIComponent,g=i.createElement("form"),u=i.getElementsByTagName("head")[0],b="_press_this_app",p=!0;if(a)if(e.match(/^https?:/))if(a+="&u="+d(e),e.match(/^https:/)&&a.match(/^http:/)&&(p=!1),t.getSelection?o=t.getSelection()+"":i.getSelection?o=i.getSelection()+"":i.selection&&(o=i.selection.createRange().text||""),a+="&buster="+(new Date).getTime(),p||(i.title&&(a+="&t="+d(i.title.substr(0,256))),o&&(a+="&s="+d(o.substr(0,512)))),n=(n=t.outerWidth||i.documentElement.clientWidth||600)<800||5e3<n?600:.7*n,d=(d=t.outerHeight||i.documentElement.clientHeight||700)<800||3e3<d?700:.9*d,p){(e.match(/\/\/(www|m)\.youtube\.com\/watch/)||e.match(/\/\/vimeo\.com\/(.+\/)?([\d]+)$/)||e.match(/\/\/(www\.)?dailymotion\.com\/video\/.+$/)||e.match(/\/\/soundcloud\.com\/.+$/)||e.match(/\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/)||e.match(/\/\/vine\.co\/v\/[^\/]+/))&&T("_embeds[]",e),l=u.getElementsByTagName("meta")||[];for(var y=0;y<l.length&&!(200<y);y++){var f=l[y],w=f.getAttribute("name"),v=f.getAttribute("property"),f=f.getAttribute("content");f&&(w?T("_meta["+w+"]",f):v&&T("_meta["+v+"]",f))}m=u.getElementsByTagName("link")||[];for(var E=0;E<m.length&&!(50<=E);E++){var _=m[E],A=_.getAttribute("rel");"canonical"!==A&&"icon"!==A&&"shortlink"!==A||T("_links["+A+"]",_.getAttribute("href"))}i.body.getElementsByClassName&&(r=i.body.getElementsByClassName("hfeed")[0]),s=(r=i.getElementById("content")||r||i.body).getElementsByTagName("img")||[];for(var B=0;B<s.length&&!(100<=B);B++)-1<(h=s[B]).src.indexOf("avatar")||-1<h.className.indexOf("avatar")||h.width&&h.width<256||h.height&&h.height<128||T("_images[]",h.src);c=i.body.getElementsByTagName("iframe")||[];for(var N=0;N<c.length&&!(50<=N);N++)T("_embeds[]",c[N].src);i.title&&T("t",i.title),o&&T("s",o),g.setAttribute("method","POST"),g.setAttribute("action",a),g.setAttribute("target",b),g.setAttribute("style","display: none;"),t.open("about:blank",b,"location,resizable,scrollbars,width="+n+",height="+d),i.body.appendChild(g),g.submit()}else t.open(a,b,"location,resizable,scrollbars,width="+n+",height="+d);else top.location.href=a;function T(t,e){var a;void 0!==e&&((a=i.createElement("input")).name=t,a.value=e,a.type="hidden",g.appendChild(a))}})(window,document,top.location.href,window.pt_url);