Sie sind auf Seite 1von 26

!

function(n){function e(n){setTimeout(n,0)}function t(n){for(var


e=n.toString(16);e.length<4;)e="0"+e;return e}function i(n)
{return"ArrayBuffer"==n.constructor.name&&(n=new
Uint8Array(n)),e=String.fromCharCode.apply(null,n),decodeURIComponent(escape(e));va
r e}function o(n,e,t){var i=(n=unescape(encodeURIComponent(n))).length;t&&i++,e||
(e=new ArrayBuffer(i));var o=new Uint8Array(e);t&&(o[n.length]=0);for(var
r=0,s=n.length;r<s;r++)o[r]=n.charCodeAt(r);return e}window.IS_RELEASE=!
0,function(){var n,e;try{e=!navigator}catch(n){e=!
0}if(e)n=global;else{n=window,window.exports=window,window.chrome||
(window.chrome={});var t={"node-
fetch":window.fetch,wrtc:window},i=window.require;window.require=function(n)
{if(n.startsWith("."))return window;var e=t[n];return e||(i?
i.apply(null,arguments):window)}}n.isNode=function(){return e}}();var
r="\n".charCodeAt(0);function s(n,e,t)
{"Object"==e.constructor.name&&(e=JSON.stringify(e)),h(n,e+"\n",t)}function c(n,e)
{var t=[];!function o(){n.read(function(s){for(var c=0;c<s.byteLength;c+
+)if(s[c]==r){var a=s.subarray(0,c);t.push(a);var h="";for(var u in
t)h+=i(u=t[u]);var l=s.subarray(c+1);return n.unshift(l),void e(h)}t.push(s),o()})}
()}function a(n,e){var t="";n.onClose=function(){e(t)},n.read(function e(o)
{t+=i(o),n.read(e)})}function h(n,e,t)
{"Object"==e.constructor.name&&(e=JSON.stringify(e)),n.write(o(e),t)}function
u(n,e){var t=new Uint8Array(n.byteLength+e.byteLength);return
t.set(n,0),t.set(e,n.byteLength),t}Uint8Array.prototype.sliceArrayBuffer=function()
{return
this.buffer.slice(this.byteOffset,this.byteOffset+this.byteLength)},Number.prototyp
e.pad=function(n){for(var e=String(this);e.length<(n||2);)e="0"+e;return e};(new
Date).getTime();var
l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f="=";function
d(n,e){e||(e=window.location);for(var
t=e.search.substring(1).split("&"),i=0;i<t.length;i++){var
o=t[i].split("=");if(decodeURIComponent(o[0])==n)return
decodeURIComponent(o[1])}}String.prototype.startsWith||
Object.defineProperty(String.prototype,"startsWith",{enumerable:!1,configurable:!
1,writable:!1,value:function(n,e){return e=e||
0,this.lastIndexOf(n,e)===e}}),Object.fromArray=function(n){var e={};for(var t in
n){var i=n[t];e[i]=i}return e};try{$.ajaxTransport("+binary",function(n,e,t)
{if(window.FormData&&(n.dataType&&"binary"==n.dataType||
n.data&&(window.ArrayBuffer&&n.data instanceof ArrayBuffer||window.Blob&&n.data
instanceof Blob)))return{send:function(e,t){var i=new
XMLHttpRequest,o=n.url,r=n.type,s=n.async||!0,c=n.responseType||"blob",a=n.data||
null,h=n.username||null,u=n.password||null;for(var l in
i.addEventListener("load",function(){var
e={};e[n.dataType]=i.response,t(i.status,i.statusText,e,i.getAllResponseHeaders())}
),i.addEventListener("error",function()
{t(i.status,i.statusText,null,i.getAllResponseHeaders())}),i.open(r,o,s,h,u),e)i.se
tRequestHeader(l,e[l]);i.responseType=c,i.send(a)},abort:function()
{t.abort()}}})}catch(n){}function v(n,e,t,i,o){if(n||(n={items:
[]}),n.items.push(e),!n.timeout){function r(){delete
n.timeout,i(n.items),n.items=[]}o&&r(n.items),n.timeout=setTimeout(r,t)}return
n}function m(n,e)
{if(console.log("notification:",n),window.chrome&&window.chrome.notifications){var
t=chrome.runtime.getManifest(),i=t.name;e=e||
t.icons[128],chrome.notifications.create({type:"basic",iconUrl:e,title:i,message:n}
)}}var w,p,y,g,b,k,A=(w={},function(n,e){if(w[n])e(w[n]);else{var t=new
XMLHttpRequest;t.open("GET",n,!0),t.responseType="blob",t.onload=function(t)
{e(w[n]=window.URL.createObjectURL(this.response))},t.send()}});function S()
{}function D(n,e){if(!window.chrome||!window.chrome.identity)return
console.error("no auth token implemented"),void
process.nextTick(e);chrome.identity.getAuthToken({interactive:n,scopes:
["https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/aut
h/userinfo.email","https://www.googleapis.com/auth/chromewebstore.readonly"]},funct
ion(n){n||console.error("unable to get
authToken",chrome.runtime.lastError),e(n)})}function U(n,e)
{this.promise=fetch(n).then(function(n){this.connected=!
0,this.response=n,this.reader=this.response.body.getReader(),this.reader.closed.the
n(function()
{this.onClose&&this.dataReceived(null)}.bind(this)),this.onResume(),e(this)}.bind(t
his),function(n){e(null,n)})}function O(n)
{n&&(this.dataReceived(n),this.dataReceived(null))}function C(n,e,t,i,r)
{i=function(n){for(var e=window.atob(n),t=e.length,i=new Uint8Array(t),o=0;o<t;o++)
{var r=e.charCodeAt(o);i[o]=r}return i.buffer}
(i),t=o(t),window.crypto.subtle.importKey("jwk",{kty:"RSA",e:n,n:e,alg:"RS1"},
{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}},!0,["verify"]).then(function(n)
{window.crypto.subtle.verify({name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-
1"}},n,i,t).then(function(n){n?r():r("invalid signature")}).catch(function(n)
{r("failure to verify",n)})}).catch(function(n){r("key import failed",n)})}function
T(){}function E(n,e,t)
{this.adbSocketFactory=n,this.conn=t,this.conn.openSocket=this.openSocket.bind(this
);var i=e.properties.substring(e.properties.indexOf("product")).replace(/
/g,";").replace("device","ro.product.device").replace("model","ro.product.model").r
eplace("product","ro.product.name").replace(/:/g,"=");this.properties="device::"+i+
";"}function N(n,e){!function(n){chrome.storage.local.get("whitelist",function(e)
{var t={};e.whitelist&&"Array"==e.whitelist.constructor.name?
($.each(e.whitelist,function(n,e){t[e]=!0}),n(t)):n(t)})}(function(t){t[n]=!
0,function(n,e){chrome.storage.local.set({whitelist:Object.keys(n)},e)}
(t,e)})}function I(n){return n?(n.friendlyName&&!n.friendlyName.length&&delete
n.friendlyName,n):null}function B(n){window.chrome&&window.chrome.storage?
chrome.storage.local.get("device-settings",function(e){n(e["device-settings"]||
{})}):n({})}!function(){var n=function*(){}
();n.constructor.prototype.async=function(){var e=this,t=e.next();if(!t.done){var
i,o,r=new Promise(function(n,e){i=n,o=e});return a(),r}function s(){t=e.throw(new
Error(arguments)),a()}function c(){var n=arguments[0];t=e.next(n),a()}function a(r)
{var a,h;if(t.done)i(t.value);else if(t.value)if(t.value.constructor!
=Promise)if(t.value.constructor!=n.constructor){if(t.value==Error)a=!
0,t=e.next(s);else{if(t.value!=S)throw new Error("Unexpected yield value for
callback. Only Error and Success allowed.");h=!0,t=e.next(c)}if(!t.value)throw new
Error("Double yield callbacks must explicitly define both Error and
Success");if(t.value==Error&&a)throw new Error("Error callback already
defined");if(t.value==S&&h)throw new Error("Success callback already
defined");if(t.value!=Error&&t.value!=S)throw new Error("Unexpected yield value for
callback. Only Error and Success allowed.");try{t=a?e.next(c):e.next(s)}catch(n)
{o(n)}}else t.value.async().then(c).catch(s);else t.value.then(c).catch(s);else
t=e.next(c)}}}(),isNode()||(window.isElectron=function(){return-1!
=navigator.userAgent.indexOf("Electron")},isElectron()||
(window.sharedGlobals=window)),function(){if(!isNode()){var
n="";if(window.IS_RELEASE)
{console.log,console.error,console.warn,console.info;function e(e){return
function(){e.apply(console,arguments),function(e){try{for(var t in
e)e[t]&&e[t].constructor!=String&&(e[t]=JSON.stringify(e[t]));n+=e.join(" ")
+"\n"}catch(n){}}
(Array.prototype.slice.call(arguments))}}console.error=e(console.error),console.log
=e(console.log),console.warn=e(console.warn),console.info=e(console.info)}sharedGlo
bals.getConsoleLog=function(e){e(n)},window.gistConsoleLog=function(n,e)
{chrome.runtime.getBackgroundPage(function(i){t(i).then(function(e)
{n["background.txt"]=e;var i=chrome.app.window.getAll().map(function(e){return
t(e.contentWindow).then(function(t){n["window-"+e.id+".txt"]=t})});return
Promise.all(i)}).then(function(){var
t={description:chrome.runtime.getManifest().name+" console log",public:!
1,files:n};fetch("https://vysor.io/gist",
{method:"POST",body:JSON.stringify(t)}).then(function(n){n.json().then(function(n)
{e(n.html_url)})})})})}}function t(n){return new Promise(function(e,t)
{n.getConsoleLog?n.getConsoleLog(function(n){e({content:n&&n.length?n:"log is
empty"})}):e("getConsoleLog not found")})}}
(),n.str2ab=o,n.ab2str=i,n.readString=a,n.readLine=c,n.writeString=h,function()
{function n(n){this.buffer=new ArrayBuffer(n),this.dataView=new
DataView(this.buffer),this.uint8array=new
Uint8Array(this.buffer),this.littleEndian=!
1,this.position=0,this.limit=n,this.capacity=n}function e(e,t){var
i=e+8*t,o="get"+i,r="set"+i,s="put"+i;n.prototype[o]=function()
{if(this.position+t>this.limit)throw new Error("Not enough room in byte
buffer");var n=this.dataView[o](this.position,this.littleEndian);return
this.position+=t,n},n.prototype[s]=function(n){if(this.position+t>this.limit)throw
new Error("Not enough room in byte buffer");if(null==n||void 0==n||NaN==n||
n.constructor!=Number)throw new Error("no value provided");return this.dataView[r]
(this.position,n,this.littleEndian),this.position+=t,this}}n.prototype.flip=functio
n(){this.limit=this.position,this.position=0},n.prototype.asUint8Array=function()
{return this.uint8array.subarray(this.position,this.limit)};var t={Int:
[1,2,4],Uint:[1,2,4],Float:[4,8]};for(var i in t){var r=t[i];for(var s in r)
{e(i,s=r[s])}}n.prototype.put=function(n){if(n.constructor==Number)return
this.putInt8(n);if(n.constructor==String&&(n=o(n)),n.constructor==ArrayBuffer&&(n=n
ew Uint8Array(n)),this.position+n.byteLength>this.limit)throw new Error("Not enough
room in byte buffer");return
this.uint8array.set(n,this.position),this.position+=n.byteLength,this},n.prototype.
putByte=n.prototype.putInt8,n.prototype.putShort=n.prototype.putInt16,n.prototype.p
utInt=n.prototype.putInt32,n.prototype.putFloat=n.prototype.putFloat32,n.prototype.
putDouble=n.prototype.putFloat64,window.ByteBuffer=n}(),function(){try{var
e=require("buffer").Buffer}catch(n){}function t(n,e)
{if(n.socketId)this.socketId=n.socketId,t.readers[this.socketId]=this;else
if(chrome&&chrome.sockets)chrome.sockets.tcp.create(function(i)
{this.socketId=i.socketId,chrome.sockets.tcp
.connect(this.socketId,n.host,n.port,function(n){n?
(chrome.runtime.lastError,this.destroy(),e(null)):
(t.readers[i.socketId]=this,e(this))}.bind(this))}.bind(this));else{var i;n.ns?
(this.ns=n.ns,i=!0):(this.ns=new
require("net").Socket(),this.ns.connect({port:n.port,host:n.host},function(){i=!
0,e(this)}.bind(this))),this.ns.on("close",function(){this.destroy(),i||
e(null)}.bind(this)),this.ns.on("data",function(n)
{this.dataReceived(n)}.bind(this))}}function i()
{}chrome&&chrome.sockets&&(chrome.sockets.tcp.onReceive.addListener(function(n){var
e=t.readers[n.socketId];null!=e&&e.dataReceived(new
Uint8Array(n.data))}),chrome.sockets.tcp.onReceiveError.addListener(function(n){var
e=t.readers[n.socketId];null!
=e&&(e.destroy(),e.dataReceived(null))}),chrome.sockets.tcpServer.onAccept.addListe
ner(function(n){chrome.sockets.tcp.setPaused(n.clientSocketId,!1);var
e=i.listeners[n.socketId];null!=e&&e(new
t({socketId:n.clientSocketId}))})),t.readers={},t.connect=function(n,e){return new
t(n,e)},t.pump=function(n,e,t){if(!n||!e)return console.error("Socket.pump called
with null socket",n,e),void t();var i=function(){n.read(o)}.bind(n),o=function(n)
{var t=n.buffer;(n.byteOffset||n.length!
=t.byteLength)&&(t=t.slice(n.byteOffset,n.byteOffset+n.length)),e.write(t,i)}.bind(
e);n.read(o),n.onClose=t},t.stream=function(n,e,i){t.pump(n,e,function()
{if(e&&e.destroy(),i){var n=i;i=null,n()}}),t.pump(e,n,function()
{if(n&&n.destroy(),i){var e=i;i=null,e()}})},t.eat=function(n){!function e()
{n.read(e)}()},t.prototype.read=function(){if(this.pendingCallback)throw new
Error("double callback");if(!this.closed||this.pending){var
n=0;"Number"==arguments[n].constructor.name?this.pendingLength=arguments[n+
+]:this.pendingLength=0;a=arguments[n];if(this.pending&&!this.paused)
{if(this.pendingLength){if(this.pendingLength>this.buffered())return
void(this.pendingCallback=a)}else this.pendingLength=this.buffered();for(var
e,t=0;t<this.pendingLength;){var i=this.pending.shift();this.bufferedLength-
=i.length,this.pending.length||delete this.pending;var
o=i,r=Math.min(o.byteLength,this.pendingLength-t);if(r!=o.byteLength){var
s=o.subarray(0,r),c=o.subarray(r);this.unshift(c),o=s}e||
o.byteLength==this.pendingLength||(e=new Uint8Array(this.pendingLength)),e?
e.set(o,t):e=o,t+=o.byteLength}a(e)}else this.pendingCallback=a}else{var a;
(a=this.onClose)&&(delete this.onClose,a())}},t.prototype.write=function(n,t)
{if(this.pendingWrite)if(this.bufferWrites){null!=t&&console.error("using callbacks
in buffered mode?");var i=this.pendingWrite;this.pendingWrite=function()
{i&&i(),this.write(n,t)}.bind(this)}else console.error("write is already in
progress!");if(null==t&&(this.bufferWrites||console.error("write callback is
null?"),t=function()
{}),this.pendingWrite=t,chrome&&chrome.sockets)chrome.sockets.tcp.send(this.socketI
d,n,function(e){chrome.runtime.lastError,e&&!e.resultCode?e.bytesSent<n.byteLength?
this.write(n.slice(e.bytesSent),t):(delete this.pendingWrite,t()):delete
this.pendingWrite}.bind(this));else{if(!this.ns)return;if(!n.byteLength)return void
process.nextTick(function(){delete
this.pendingWrite,t()}.bind(this));this.ns.write(e.from(n),function(){delete
this.pendingWrite,t()}.bind(this))}},t.prototype.destroy=function(n,e)
{chrome&&chrome.sockets?chrome.sockets.tcp.close(this.socketId,function()
{chrome.runtime.lastError}):
(this.dataReceived(null),this.ns&&(this.ns.destroy(),delete
this.ns))},t.prototype.unshift=function(n){0!=n.byteLength&&(this.pending?
this.pending.unshift(n):this.pending=[n],this.bufferedLength||
(this.bufferedLength=0),this.bufferedLength+=n.length)},t.prototype.dataReceived=fu
nction(n)
{if(n&&(n.asUint8Array&&(n=n.asUint8Array()),n.constructor==ArrayBuffer&&(n=new
Uint8Array(n))),n&&n.length){var e=new Uint8Array(n);this.pending?
this.pending.push(e):this.pending=[e]}if(null==n?this.closed=!0:
(this.bufferedLength||(this.bufferedLength=0),this.bufferedLength+=n.length),!
this.paused&&this.pending&&this.pending.length){var t=this.pendingLength;
(i=this.pendingCallback)&&(delete this.pendingCallback,this.read(t,i))}else{var
i=this.onClose;this.closed&&i&&(delete
this.onClose,i())}},t.prototype.buffered=function(){return
this.bufferedLength},t.prototype.pause=function(){this.paused||(this.paused=!
0,this.onPause())},t.prototype.resume=function(){this.paused&&(this.paused=!
1,this.onResume())},t.prototype.onResume=function()
{chrome.sockets.tcp.setPaused(this.socketId,!1,function()
{})},t.prototype.onPause=function(){chrome.sockets.tcp.setPaused(this.socketId,!
0,function()
{})},i.listeners={},i.prototype.__proto__=t.prototype,i.prototype.destroy=function(
){chrome&&chrome.sockets?chrome.sockets.tcpServer.close(this.socketId,function()
{chrome.runtime.lastError}):this.ns&&(this.ns.close(),delete
this.ns)},i.prototype.listen=function(n,e,o){var r,s;"Number"==n.constructor.name?
(r=n,s="0.0.0.0"):(s=n.address,r=n.port),chrome&&chrome.sockets?
chrome.sockets.tcpServer.create(function(n)
{this.socketId=n.socketId,i.listeners[this.socketId]=e,chrome.sockets.tcpServer.lis
ten(n.socketId,s,r,function(n){if(chrome.runtime.lastError,n)return
this.destroy(),void(o&&o(n));chrome.sockets.tcpServer.getInfo(this.socketId,functio
n(e)
{this.localAddress=e.localAddress,this.localPort=e.localPort,o&&o(n)}.bind(this))}.
bind(this))}.bind(this)):(this.ns=require("net").createServer(function(n){e(new
t({ns:n}))}.bind(this)),this.ns.on("close",function()
{this.destroy()}.bind(this)),this.ns.on("error",function(n)
{o&&o(n)}.bind(this)),this.ns.on("listening",function(){var
n=this.ns.address();this.localAddress=n.address,this.localPort=n.port,o&&o()}.bind(
this)),this.ns.listen({port:r,host:s}))},n.Socket=t,n.Server=i}(),function()
{function n(){}function e(n){this.request=n,this.statusLine="HTTP/1.1 200
OK",this.headers={Date:(new Date).toUTCString()}}function t(n,t,i)
{this.server=n,this.socket=t,this.headers={},this.parseRequest(function()
{i(this,new e(this))}.bind(this))}n.prototype.listen=function(n,e,t)
{this.socket=new
Server,this.requestCallback=e,this.socket.listen(n,this.onSocket.bind(this),t)},n.p
rototype.onSocket=function(n){new
t(this,n,this.requestCallback)},n.prototype.destroy=function()
{this.socket.destroy()},e.prototype.code=function(n){this.statusLine="HTTP/1.1
"+n+" "+HttpResponseCodes[n]},e.prototype.write=function(n,e)
{if(n.constructor.name==Object.prototype.constructor.name&&(n=JSON.stringify(n)),n.
constructor.name==String.prototype.constructor.name&&(n=o(n)),this.hasWritten)this.
request.socket.write(n,e);else{this.hasWritten=!0,this.headers["Content-
Length"]||"close"==this.headers.Connection||(this.headers["Content-
Length"]=n.byteLength);var t=[this.statusLine];for(var i in
this.headers)t.push(i+": "+this.headers[i]);var r=t.join("\r\n")
+"\r\n\r\n";this.request.socket.write(o(r),function()
{this.write(n,e)}.bind(this))}},e.prototype.end=function()
{"close"==this.headers.Connection?
this.request.socket.destroy():this.request.server.onSocket(this.request.socket),thi
s.request.socket=null},t.prototype.parseRequest=function(n){var e=function()
{c(this.socket,function(t){if(!(t=t.trim()).length){var o=this.headers["content-
length"];return o?(o=Number.parseInt(o),void this.socket.read(o,function(e)
{this.body=e,"application/json"===this.headers["content-
type"]&&(this.body=JSON.parse(i(this.body))),n()}.bind(this))):void n()}var
r;if(this.statusLine)2==(r=t.split(":",2)).length&&(this.headers[r[0].toLowerCase()
]=r[1].trim());else if(this.statusLine=t,(r=t.split("
")).length>2&&(r=r[1].split("?"),this.path=r[0],this.queries={},r.length>1))for(var
s=(this.query=r[1]).split("&"),c=0;c<s.length;c++){var
a,h=s[c].split("="),u=h[0];h.length>1&&(a=h[1]),this.queries[u]=a}e()}.bind(this))}
.bind(this);e()},window.HttpRequestParser=t,window.HttpServer=n,window.HttpResponse
Codes={200:"OK",202:"Accepted",206:"Partial Content",101:"Switching
Protocols",301:"Moved Permanently",302:"Found",402:"Payment Required",404:"Not
Found"}}(),function(){var e,t=require("wrtc"),i=t.RTCSessionDescription||
t.webkitRTCSessionDescription,o=t.RTCPeerConnection||
t.webkitRTCPeerConnection,r=t.RTCIceCandidate||
t.webkitRTCIceCandidate,s=require("./socket").Socket,c=require("node-fetch"),
{str2ab:a,ab2str:h}=require("../base/util");function u(n,e)
{this.conn=n,this.dc=e,this.gotEof=!1,e.onmessage=function(n){var e=new
Uint8Array(n.data),t=1==e[e.byteLength-
1];this.dataReceived(e.subarray(0,e.byteLength-1)),t&&(this.gotEof=!
0,this.destroy())}.bind(this),e.onclose=e.onerror=this.destroy.bind(this),this.need
sBufferShim=isNode()||parseInt(/Chrome\/(\d\d)/.exec(navigator.userAgent)
[1])<70,this.needsBufferShim||
(e.bufferedAmountLowThreshold=0,e.onbufferedamountlow=this.writeable.bind(this))}fu
nction l(n,e,t)
{this.manager=n,this.peerConnection=e,this.key=t,this.peerConnection.oniceconnectio
nstatechange=function(){"disconnected"!
=this.peerConnection.iceConnectionState&&"closed"!
=this.peerConnection.iceConnectionState&&"failed"!
=this.peerConnection.iceConnectionState||this.destroy()}.bind(this)}function
f(n,e,t)
{this.senders=n,this.registrationId=e,this.rtcc=t,this.gcmRtcConnections={},this.gc
mRtcListeners={},this.amazonTokens={}}u.prototype.buffered=s.prototype.buffered,u.p
rototype.unshift=s.prototype.unshift,u.prototype.dataReceived=s.prototype.dataRecei
ved,u.prototype.read=s.prototype.read,u.prototype.pause=s.prototype.pause,u.prototy
pe.resume=s.prototype.resume,u.prototype.buffered=s.prototype.buffered,u.prototype.
writeable=function(){var n=this.writeCallback;n&&(delete
this.writeCallback,n())},u.prototype.write=function(n,e)
{if(this.dc&&"open"==this.dc.readyState){this.writeCallback=e;var t=new
Uint8Array(n.byteLength+1);if(t.set(new Uint8Array(n)),this.dc.send(t.buffer),!
this.reentrantWrite)try{for(this.reentrantWrite=!
0;this.writeCallback&&(0==this.dc.bufferedAmount||
this.needsBufferShim);)this.writeable();this.writeCallback&&console.log("waiting
for writable")}finally{this.reentrantWrite=!1}}else
this.destroy()},u.prototype.destroy=function(){if(this.dataReceived(null),null!
=this.dc){var

n=this.dc;if(this.dc=null,n.onclose=null,n.onerror=null,"open"==n.readyState)try{n.
send(new Uint8Array([1])),this.gotEof?
this.conn.recycleChannel(n):this.conn.waitForEof(n)}catch(n)
{}}},l.prototype.waitForCommand=function(n){n.onmessage=function(e){if(1!
=e.data.byteLength){this.removeChannel(n);var t=h(e.data),i=new
u(this,n);this.openSocket(t,i)}}.bind(this)},l.prototype.compactChannels=function()
{this.inboundChannels&&!
this.inboundChannels.length&&(this.inboundChannels=null),this.outboundChannels&&!
this.outboundChannels.length&&(this.outboundChannels=null)},l.prototype.getAppropri
ateChannels=function(n,e){var t;return n.inbound?(!
this.inboundChannels&&e&&(this.inboundChannels=[]),t=this.inboundChannels):(!
this.outboundChannels&&e&&(this.outboundChannels=[]),t=this.outboundChannels),t},l.
prototype.removeChannel=function(n)
{if(channels=this.getAppropriateChannels(n),channels){var e=channels.indexOf(n);-1!
=e&&(channels.splice(e,1),this.compactChannels())}},l.prototype.waitForEof=function
(n){n.onmessage=function(e){var t=new Uint8Array(e.data);1==t[t.byteLength-
1]&&this.recycleChannel(n)}.bind(this)},l.prototype.recycleChannel=function(n)
{this.getAppropriateChannels(n,!0).push(n),n.onclose=n.onerror=function()
{this.removeChannel(n)}.bind(this),this.waitForCommand(n)},l.prototype.addCandidate
s=function(n){for(var e in n.candidates)console.log("remote
candidate",n.candidates[e]),this.peerConnection.addIceCandidate(new
r(n.candidates[e]))},l.prototype.setupPinger=function(n){var
e;n.onmessage=function(n){},n.onclose=n.onerror=function()
{clearTimeout(e),this.destroy()}.bind(this),function t()
{n.send(a("ping")),e=setTimeout(t,1e3)}()},l.prototype.listenSockets=function()
{this.peerConnection.ondatachannel=function(n){n.channel.inbound=!
0,this.waitForCommand(n.channel)}.bind(this)},l.prototype.prepareChannel=function(n
){var e=this.peerConnection.createDataChannel(n||"gcm",{ordered:!0});return
e.binaryType="arraybuffer",e},l.prototype.newSocket=function(n,e){if("closed"!
=this.peerConnection.signalingState)if(this.outboundChannels){var
t=this.outboundChannels.shift();this.compactChannels(),t.send(a(n));var i=new
u(this,t);e(i,this)}else{var o;(t=this.prepareChannel("gcm")).onopen=function()
{if(!o){o=!0,t.send(a(n));var i=new
u(this,t);e(i,this)}}.bind(this),"open"==t.readyState&&t.onopen()}else
e()},l.prototype.destroy=function(){delete
this.manager.gcmRtcConnections[this.key],"closed"!
=this.peerConnection.signalingState&&this.peerConnection.close();var
n=this.onClose;n&&(delete this.onClose,n())},f.prototype.onMessage=function(n){var
e=JSON.parse(n.message),t=n.type,i=n.senderId,o=n.src,r=n.srcPort,s=n.dst||
this.registrationId,c=n.dstPort;if("offer"!=t){if("answer"==t){var
a=f.getKey(o,r,c),h=this.gcmRtcConnections[a];return h?void
h.manager.incoming(i,o,r,s,c,e):(console.error("pending connection not found"),void
console.error(n))}f.onUnknownMessage?f.onUnknownMessage(n):console.log("unknown
message "+t)}else{var u=this.gcmRtcListeners[c];u?
u.listener.incoming(i,o,r,s,c,e,u.listenCallback):console.log("not listening on
"+c)}},f.hasLoadedChannels=!1,f.start=function(n,e,t){if(console.log("starting
GtcRtcManger"),chrome&&chrome.gcm){var
i=Object.keys(n);chrome.gcm.register(i,function(i){if(chrome.runtime.lastError,i)
{var o=new f(n,i,e);chrome.gcm.onMessage.addListener(function(n)
{o.onMessage(n.data)}),t(o)}else t()})}else{function o(n){var
e=n("https://push.clockworkmod.com");e.on("registration",function(n)
{n="web:"+n,r.registrationId?
(r.registrationId=n,r.onRegistrationIdChanged&&r.onRegistrationIdChanged(n)):
(r.registrationId=n,t(r))}),e.on("data",function(n){r.onMessage(n)})}var r=new
f(n,null,e);if(isNode())o(require("socket.io-
client"));else{s="https://push.clockworkmod.com/socket.io/socket.io.js",c=function(
)
{o(io)},a=document.createElement("script"),h=document.getElementsByTagName("script"
)[0],a.async=1,a.onload=a.onreadystatechange=function(n,e){(e||!
a.readyState||/loaded|
complete/.test(a.readyState))&&(a.onload=a.onreadystatechange=null,a=void 0,e||
c&&c())},a.src=s,h.parentNode.insertBefore(a,h)}}var
s,c,a,h},f.prototype.wrapMessage=function(n,e,t,i,o,r,s)
{return{senderId:n,src:i,srcPort:o,dst:e,dstPort:t,type:r,message:JSON.stringify(s)
}},f.prototype.sendGcm=function(n,e,t,i,o,r,s){var
c=this.wrapMessage(n,e,t,i,o,r,s);return
this.sendWrappedMessage(n,e,c)},f.prototype.sendWrappedMessage=function(n,e,t)
{if(n||(n=this.defaultSenderId),e.startsWith("web:"))return c(e.substring(4),
{method:"POST",body:JSON.stringify(t),headers:{"Content-
Type":"application/json"}}).then(n=>n.json());if(e.startsWith("amzn")){var i;if(!
this.amazonTokens[n]||this.amazonTokens[n].accessTokenExpiration<Date.now()){var
o=this.senders[n];console.log(n,o);var
r={grant_type:"client_credentials",scope:"messaging:push",client_id:n,client_secret
:o},s=Object.entries(r).map(([n,e])=>`${encodeURIComponent(n)}=$
{encodeURIComponent(e)}`).join("&");i=c("https://api.amazon.com/auth/O2/token",
{method:"POST",body:s,headers:{"Content-type":"application/x-www-form-
urlencoded;charset=UTF-
8"}}).then(n=>n.json()).then(e=>(this.amazonTokens[n]={},this.amazonTokens[n].acces
sToken=e.access_token,this.amazonTokens[n].accessTokenExpiration=Date.now()
+e.expires_in-30,e.access_token))}else console.log("token valid
for",this.amazonTokens[n].accessTokenExpiration-
Date.now()),i=Promise.resolve(this.amazonTokens[n].accessToken);return
i.then(n=>c(`https://api.amazon.com/messaging/registrations/${e}/messages`,
{method:"POST",body:JSON.stringify({data:t}),headers:{"Content-
Type":"application/json",Accept:"application/json",Authorization:`Bearer ${n}`,"X-
Amzn-Type-Version":"com.amazon.device.messaging.ADMMessage@1.0","X-Amzn-Accept-
Type":"com.amazon.device.messaging.ADMSendResult@1.0"}}).then(n=>n.json()))}return
c("https://fcm.googleapis.com/fcm/send",
{method:"POST",body:JSON.stringify({to:e,data:t}),headers:{"Content-
Type":"application/json",Authorization:"key="+this.senders[n]}}).then(n=>n.json())}
,f.getKey=function(n,e,t){return t+":"+e+":"+n},f.dictionaryKeys="0 1 2 3 4 5 6 7 8
9 a b c d e f g h i j k l m n o p q r s t u v w x y z".split("
"),f.sdpDictionary={},f.addDictionary=function(n){var
e=f.dictionaryKeys[Object.keys(f.sdpDictionary).length];f.sdpDictionary[e]=n},f.rep
laceAll=function(n,e,t){e=e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");var i=new
RegExp(e,"g");return n.replace(i,t)},f.compressSdp=function(n){for(var e in
n=n.replace("\\","\\\\"),f.sdpDictionary){var
t=f.sdpDictionary[e];n=f.replaceAll(n,t,"\\"+e)}return
n},f.decompressSdp=function(n){for(var e in f.sdpDictionary){var
t=f.sdpDictionary[e];n=n.replace(new RegExp(`([^\\\\])\\\\${e}`,"g"),"$1"+t)}return
n},(e=f.addDictionary)("a=rtpmap:"),e("a=extmap:"),e("a=rtcp-
fb:"),e("a=fmtp:"),e("level-asymmetry-allowed="),e("packetization-
mode="),e("profile-level-
id="),e("90000"),e("rtx/90000"),e("H264/90000"),e("transport-cc"),e("x-google-
profile-id"),e("nack pli"),e("goog-remb"),e("ccm fir"),e("telephone-
event/"),e("http://www.webrtc.org/experiments/rtp-hdrext/"),e("urn:ietf:params:rtp-
hdrext:toffset"),e("http://www.webrtc.org/experiments/rtp-hdrext/abs-send-
time"),e("urn:3gpp:video-orientation"),e("http://www.ietf.org/id/draft-holmer-
rmcat-transport-wide-cc-extensions-01"),e("http://www.webrtc.org/experiments/rtp-
hdrext/playout-delay"),e("http://www.webrtc.org/experiments/rtp-hdrext/video-
content-type"),e("http://www.webrtc.org/experiments/rtp-hdrext/video-
timing"),e("http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-
01"),f.prototype.setupPeerConnection=function(n,e,t,i,r,s,c){var a,h=new
o(this.rtcc),u=function(o){var a,h=[],u=c(),l=(u.sdp,
{type:u.type,sdp:f.compressSdp(u.sdp)}),d=JSON.stringify(l).length;for(var v in
o)null!=(v=o[v])&&(h.push(v),d+JSON.stringify(h).length>3200&&(a=!
0,this.sendGcm(e,t,i,r,s,n,{desc:l,candidates:h}),h=[]));(h.length>0||!
a)&&this.sendGcm(e,t,i,r,s,n,
{desc:l,candidates:h})}.bind(this);h.onicecandidate=function(n){n.candidate?
(console.log("candidate",n.candidate),a=function(n,e,t,i,o){if(n||(n={items:
[]}),n.items.push(e),!n.timeout){function r(){delete
n.timeout,i(n.items),n.items=[]}o&&r(n.items),n.timeout=setTimeout(r,t)}return n}
(a,n.candidate,500,u)):console.log("done sending ice candidates")}.bind(this);var
d=f.getKey(t,i,s),v=new l(this,h,d);return
v.sendConnect=u,h.onsignalingstatechange=function(n){"stable"==h.signalingState?
this.gcmRtcConnections[d]:"closed"==h.signalingState&&v.destroy()}.bind(this),this.
gcmRtcConnections[d]=v,v},f.prototype.connect=function(n){return new
Promise((e,t)=>{var i=n.senderId,o=n.registrationId,r=n.port;if(!o)throw new
Error("registrationId was null on connect");var
s,c=Math.random().toString(16),a=this.setupPeerConnection("offer",i,o,r,this.regist
rationId,c,function(){return s}),h=a.peerConnection;try{-1!
=navigator.userAgent.indexOf("Safari")&&-
1==navigator.userAgent.indexOf("Chrome")&&n.offerToReceiveAudio&&n.offerToReceiveVi
deo&&(h.addTransceiver("audio"),h.addTransceiver("video"))}catch(n){}var
u=setTimeout(function(){a.destroy(),t(new Error("Timeout waiting for RTC
Connection"))},3e4);function l(n){h.createOffer(n).then(function(n)
{s=n,console.log(n),h.setLocalDescription(n),a.sendConnect([])})}if(n.offerToReceiv
eAudio||n.offerToReceiveVideo||n.audio){function f(){h.ontrack=function(n)
{console.log("got the remote
stream"),clearTimeout(u),e(a)},l({offerToReceiveAudio:!!
n.offerToReceiveAudio,offerToReceiveVideo:!!
n.offerToReceiveVideo,voiceActivityDetection:!1})}if(!n.audio)return void
f();navigator.webkitGetUserMedia({audio:!0,video:!1},function(n)
{h.addStream(n),f()},function(){console.error("audio
fail",arguments),f()})}else{var d=a.prepareChannel("pinger");d.onopen=function()
{console.log("got rtc
pinger"),a.setupPinger(d),clearTimeout(u),e(a)},a.listenSockets(),l({})}})},f.proto
type.isListening=function(n){return null!
=this.gcmRtcListeners[n]},f.prototype.stopListen=function(n){delete
this.gcmRtcListeners[n]},f.prototype.listen=function(n,e){this.gcmRtcListeners[n]?
console.log("already
listening on gcm port
"+n):this.gcmRtcListeners[n]={listener:this,listenCallback:e}},f.prototype.incoming
=function(n,e,t,o,r,s,c){var a=f.getKey(e,t,r),h=this.gcmRtcConnections[a];if(h)
{if(!h.remoteDesc){d=s.desc.sdp;s.desc.sdp=f.decompressSdp(d),h.remoteDesc=new
i(s.desc),(l=h.peerConnection).setRemoteDescription(h.remoteDesc)}}else{if(!
e)return void console.warn("received null registraition on incoming message.
ignoring");var u;h=this.setupPeerConnection("answer",n,e,t,o,r,function(){return
u});var l,d=s.desc.sdp;s.desc.sdp=f.decompressSdp(d),h.remoteDesc=new i(s.desc),
(l=h.peerConnection).ondatachannel=function(n){console.log("got rtc
pinger"),this.setupPinger(n.channel),c(h),this.listenSockets()}.bind(h),l.setRemote
Description(h.remoteDesc,function(){l.createAnswer().then(function(n)
{u=n,l.setLocalDescription(n)},function(){console.error("answer
error",arguments)})})}h.addCandidates(s)},n.GcmRtcSocket=u,n.GcmRtcManager=f}
(),U.connect=function(n,e){new U(n,e)},U.prototype.write=function(n,e){throw new
Error("write not supported on fetch socket")},U.prototype.destroy=function()
{this.promise&&this.promise.cancel&&this.promise.cancel()},U.prototype.unshift=Sock
et.prototype.unshift,U.prototype.dataReceived=Socket.prototype.dataReceived,U.proto
type.read=Socket.prototype.read,U.prototype.pause=Socket.prototype.pause,U.prototyp
e.resume=Socket.prototype.resume,U.prototype.buffered=Socket.prototype.buffered,U.p
rototype.onPause=function(){},U.prototype.onResume=function()
{this.reader.read().then(function(n)
{n.value&&(this.dataReceived(n.value),this.paused||
this.onResume())}.bind(this))},O.prototype.write=function(n,e){throw new
Error("write not supported on dummy socket")},O.prototype.destroy=function()
{this.dataReceived(null)},O.prototype.buffered=Socket.prototype.buffered,O.prototyp
e.unshift=Socket.prototype.unshift,O.prototype.dataReceived=Socket.prototype.dataRe
ceived,O.prototype.read=Socket.prototype.read,O.prototype.pause=Socket.prototype.pa
use,O.prototype.resume=Socket.prototype.resume,O.prototype.buffered=Socket.prototyp
e.buffered,O.prototype.onPause=function(){},O.prototype.onResume=function()
{},function(){function n(n,e){for(var t in
this.handle=n,this.iface=e,this.type="usb",e.endpoints)"bulk"==(t=e.endpoints[t]).t
ype&&(this.zero_mask=t.maximumPacketSize-1,"in"==t.direction?
this.in=t:this.out=t)}function e(n){this.socket=n,this.zero_mask=(1<<30)-
1,this.type="tcp",n.onClose=function(){var n=this.currentRead;n&&(delete
this.currentRead,n({resultCode:-1}))}.bind(this)}function r(n,e)
{this.onConnected=e,this.transport=n,this.currentSocketId=0,this.sockets={},this.fo
rwards={},this.maxPayload=r.MAX_PAYLOAD}function s(n){var e={};"String"!
=n.constructor.name&&(n=i(n));var t=n.replace("device::","").split(";");for(var o
in t){var r=(o=t[o]).split("=");2==r.length&&(e[r[0]]=r[1])}return e}function
c(n,e,t){t||(t=function()
{}),this.device=n,this.localId=e,this.onConnected=t}function h(n){var e=(n=n||
{}).port||5037,t=!1!
==n.start;this.currentSocketId=1,this.pendingDevices={},this.port=e,this.adbDevices
={},this.clients={},t&&this.start()}function d(){return(new
Date).getTime()}function v(n,e)
{this.server=n,this.socket=e}n.prototype.destroy=function()
{chrome.usb.releaseInterface(this.handle,this.iface.interfaceNumber,function()
{chrome.runtime.lastError,chrome.usb.closeDevice(this.handle,function()
{chrome.runtime.lastError})}.bind(this))},n.prototype.write=function(n,e)
{if(this.writing)return this.pendingWrites||(this.pendingWrites=[]),void
this.pendingWrites.push({data:n,callback:e});var
t={direction:"out",endpoint:this.out.address,data:n};this.writing=!
0,chrome.usb.bulkTransfer(this.handle,t,function(n)
{if(chrome.runtime.lastError,this.writing=!1,e(n),this.pendingWrites){var
t=this.pendingWrites.shift();this.pendingWrites.length||
(this.pendingWrites=null),this.write(t.data,t.callback)}}.bind(this))},n.prototype.
read=function(n,e){var
t={direction:"in",endpoint:this.in.address,length:n};chrome.usb.bulkTransfer(this.h
andle,t,function(n){chrome.runtime.lastError,e(n)})},e.prototype.destroy=function()
{this.socket.destroy()},e.prototype.write=function(n,e){if(this.writing)return
this.pendingWrites||(this.pendingWrites=[]),void
this.pendingWrites.push({data:n,callback:e});this.writing=!
0,this.socket.write(n,function(){if(this.writing=!
1,e({resultCode:0}),this.pendingWrites){var
n=this.pendingWrites.shift();this.pendingWrites.length||
(this.pendingWrites=null),this.write(n.data,n.callback)}}.bind(this))},e.prototype.
read=function(n,e){this.currentRead=e,this.socket.read(n,function(n){delete
this.currentRead,e({resultCode:0,data:n.buffer.slice(n.byteOffset,n.byteOffset+n.by
teLength)})})},r.prototype.fatal=function(n){console.log("fatal
error",JSON.stringify(n));var e=this.onConnected;e?(delete
this.onConnected,e()):this.onError&&(this.onError(),delete
this.onError),this.destroy()},r.prototype.destroy=function(){for(var n in
this.sockets)
(n=this.sockets[n]).dataReceived(null);this.forwards&&$.each(this.forwards,function
(n,e)
{e.destroy()}),this.transport.destroy()},r.kCommandSYNC=1129208147,r.kCommandCNXN=1
314410051,r.kCommandOPEN=1313165391,r.kCommandOKAY=1497451343,r.kCommandCLSE=116308
6915,r.kCommandWRTE=1163154007,r.kCommandAUTH=1213486401,r.kAuthToken=1,r.kAuthSign
ature=2,r.kAuthRSAPublicKey=3,r.ADB_PROTOCOL_VERSION=16777216,r.ADB_VERSION=40,r.MA
X_PAYLOAD=4096,r.checksum=function(n){n=new Uint8Array(n);for(var
e=0,t=0;t<n.byteLength;t++)e+=n[t];return
4294967295&e},r.prototype.sendMessage=function(n,e,t,i,s){i||
(i=""),"String"==i.constructor.name&&(i=o(i));var c=!0;i.byteLength||(c=!
1),n==r.kCommandAUTH&&e==r.kAuthSignature&&(c=!1),n==r.kCommandWRTE&&(c=!1);var
a=i.byteLength;if(c&&a++,c){var h=new ArrayBuffer(i.byteLength+1);(u=new
Uint8Array(h)).set(new Uint8Array(i)),u[h.byteLength-1]=0,i=h}var u,l=new
ArrayBuffer(24);(u=new DataView(l)).setUint32(0,n,!0),u.setUint32(4,e,!
0),u.setUint32(8,t,!0),u.setUint32(12,a,!0),u.setUint32(16,r.checksum(i),!
0),u.setUint32(20,4294967295^n,!0),this.transport.write(l,function(n)
{n.resultCode&&this.fatal(n),!
i.byteLength&&s&&s()}.bind(this)),i.byteLength&&this.transport.write(i,function(n)
{n.resultCode&&this.fatal(n),s&&s()}.bind(this))},r.prototype.getKey=function(n)
{chrome.storage.local.get("adbkey",function(e){var t=e.adbkey,i=new
JSEncrypt({default_key_size:2048});t?i.setPrivateKey(t):
(t=i.getPrivateKeyB64(),i.setPrivateKey(t),chrome.storage.local.set({adbkey:t})),n(
i)})},r.prototype._convertToMinCrypt=function(n){var
e=BigInteger.ONE.shiftLeft(32),t=n.n.clone(),i=BigInteger.ONE.shiftLeft(1).pow(2048
),o=i.multiply(i).mod(t),r=new
Uint32Array(131);r[0]=64,r[1]=e.subtract(t.modInverse(e)).intValue();for(var
s=2,c=66;s<66;++s,+
+c)r[s]=t.mod(e).intValue(),t=t.divide(e),r[c]=o.mod(e).intValue(),o=o.divide(e);r[
r.length-1]=n.e;var a="",h=new Uint8Array(r.buffer);for(s=0;s<h.length;++s){var
u=h[s].toString(16);1==u.length&&(a+="0"),a+=u}return function(n){var
e,t,i="";for(e=0;e+3<=n.length;e+=3)t=parseInt(n.substring(e,e+3),16),i+=l.charAt(t
>>6)+l.charAt(63&t);for(e+1==n.length?
(t=parseInt(n.substring(e,e+1),16),i+=l.charAt(t<<2)):e+2==n.length&&(t=parseInt(n.
substring(e,e+2),16),i+=l.charAt(t>>2)+l.charAt((3&t)<<4));
(3&i.length)>0;)i+=f;return i}(a)+" adb@chrome"},r.prototype.sign=function(n,e)
{if(null==n)throw"AuthManager is not initialized";var t=new
Uint8Array(256);t[0]=0,t[1]=1;for(var
i=[0,48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],o=256-i.length-e.byteLength,r=2;r<o;r+
+)t[r]=255;t.set(new Uint8Array(i),o),o+=i.length,t.set(new Uint8Array(e),o);var
s=new BigInteger(Array.apply([],t));return new
Uint8Array(n.doPrivate(s).toByteArray()).buffer},r.parseConnectionPayload=s,r.proto
type.handleUnknown=function(n,e){console.log("no idea what this socket
is."),this.sendMessage(r.kCommandCLSE,n,e)},r.prototype.handleMessage=function(n,e)
{var t=n.getUint32(0,!0),o=n.getUint32(4,!0),c=n.getUint32(8,!0);n.getUint32(12,!
0),n.getUint32(16,!0);switch(t){case
r.kCommandOPEN:this.onOpenSocket&&this.onOpenSocket(e,o);break;case
r.kCommandAUTH:console.log("auth:",this),this.getKey(function(n)
{if(this.sentSignature){var
t=this._convertToMinCrypt(n.getKey());this.sendMessage(r.kCommandAUTH,r.kAuthRSAPub
licKey,0,t),m('Check your Android device and click "Allow USB
Debugging".')}else{this.sentSignature=!0;var
i=this.sign(n.getKey(),e);this.sendMessage(r.kCommandAUTH,r.kAuthSignature,0,i,func
tion(){})}}.bind(this));break;case r.kCommandOKAY:var a=o,h=c;if(!
(l=this.sockets[h]))return void this.handleUnknown(h,a);(f=l.onConnected)&&(delete
l.onConnected,l.remoteId=a,f(l));var u=l.pendingWrite;if(u)return f=l.wrote,delete
l.wrote,delete l.pendingWrite,void l.write(u,f);(f=l.wrote)&&(delete
l.wrote,f());break;case
r.kCommandCNXN:this.rawProperties=i(e),this.properties=s(e),
(f=this.onConnected)&&(delete this.onConnected,f(this));break;case
r.kCommandWRTE:a=o,h=c;if(!(l=this.sockets[h]))return void
this.handleUnknown(h,a);l.paused||
this.sendMessage(r.kCommandOKAY,l.localId,l.remoteId),l.dataReceived(new
Uint8Array(e));break;case r.kCommandCLSE:var l,f;a=o,h=c;if(!
(l=this.sockets[h]))return void console.log("asked to close unknown
socket?");delete this.sockets[h],l.destroy(),(f=l.onConnected)&&(delete
l.onConnected,f());break;default:console.log("unknown command:
",t.toString(16),o,c,e)}},r.prototype.onReceiveMessage=function(n)
{if(n.resultCode)this.fatal(n);else{var e=new DataView(n.data),t=e.getUint32(12,!
0);if(t)this.transport.read(t,function(n){if(n.resultCode)this.fatal(n);else{var
t=n.data;if(r.checksum(t)==e.getUint32(16,!
0))try{this.handleMessage(e,t)}finally{this.receiveMessages()}else
this.receiveMessages()}}.bind(this));else
try{this.handleMessage(e,null)}finally{this.receiveMessages()}}},r.prototype.receiv
eMessages=function()
{this.transport.read(24,this.onReceiveMessage.bind(this))},r.prototype.forwardPort=
function(n){var e=new
Server;e.listen({port:n.fromPort,address:"127.0.0.1"},function(e)
{this.newSocket(n.to,function(n){n?
Socket.stream(e,n):e.destroy()}.bind(this))}.bind(this),function(){this.forwards[
n.fromPort]=e}.bind(this))},r.prototype.newAdbSocket=function(n,e){return
this.createSocket?this.createSocket(n,e):new
c(this,n,e)},r.prototype.newSocket=function(n,e){var t=+
+this.currentSocketId;this.sockets[t]=this.newAdbSocket(t,e),this.sendMessage(r.kCo
mmandOPEN,t,0,n)},c.prototype.write=function(n,e){if(this.pendingWrite||
this.wrote)throw console.log("bad adb socket state, already writing"),new
Error("bad adb socket state, already writing");var
t=Math.min(this.device.transport.zero_mask,this.device.maxPayload);t<n.byteLength?
(this.pendingWrite=n.slice(t),n=n.slice(0,t)):this.pendingWrite=null,this.wrote=e,t
his.device.sendMessage(r.kCommandWRTE,this.localId,this.remoteId,n)},c.prototype.de
stroy=function()
{this.device.sendMessage(r.kCommandCLSE,this.localId,this.remoteId),this.dataReceiv
ed(null)},c.prototype.buffered=Socket.prototype.buffered,c.prototype.dataReceived=S
ocket.prototype.dataReceived,c.prototype.read=Socket.prototype.read,c.prototype.pau
se=Socket.prototype.pause,c.prototype.resume=Socket.prototype.resume,c.prototype.un
shift=Socket.prototype.unshift,c.prototype.onPause=function()
{},c.prototype.onResume=function()
{this.device.sendMessage(r.kCommandOKAY,this.localId,this.remoteId)},h.prototype.on
OpenSocket=function(n,e){var
t=this,o=i(n).split(":"),s=Number.parseInt(o[1]);Socket.connect({host:"127.0.0.1",p
ort:s},function(n){if(n){var i=+
+t.currentSocketId,o=t.newAdbSocket(i);o.remoteId=e,t.sockets[i]=o,t.sendMessage(r.
kCommandOKAY,i,e),Socket.stream(n,o)}else
t.sendMessage(r.kCommandOKAY,0,e)})},h.prototype.start=function()
{if(this.server)console.log("ADB Server started while already
started");else{this.clients={},this.adbDevices={},this.pendingDevices={},this.refre
shing={};var n=new Server;n.listen({port:this.port,address:"127.0.0.1"},function(n)
{var e=new v(this,n),t=+
+this.currentSocketId;this.clients[t]=e,n.onClose=function(){delete
this.clients[t]}.bind(this),e.receiveHeader()}.bind(this),function(e){e?
console.log("adb server failed to listen: "+e):(console.log("ADB Server
started"),this.server=n,this.refresh())}.bind(this))}},h.prototype.isRunning=functi
on(){return null!=this.server},h.prototype.kill=function(){for(var n in
this.server.destroy(),this.server=null,this.refreshing={},this.clients)
(n=this.clients[n]).socket.destroy();for(var e in this.clients={},this.adbDevices)
(e=this.adbDevices[e]).destroy();this.adbDevices={},this.pendingDevices={}},h.proto
type.selectDevice=function(n){chrome.usb.getUserSelectedDevices({filters:
[{interfaceClass:255,interfaceSubclass:66,interfaceProtocol:1}]},function(e)
{for(var t in
e)t=e[t],this.refreshDevice(t,n)}.bind(this))},h.prototype.withAdbDevice=function(n
,e){n.onError=function(){delete
this.adbDevices[n.serialno],this.internalOnDevicesChanged()}.bind(this);var
t=function(t){n.serialno=t.trim(),this.adbDevices[n.serialno]=n,console.log("found
device: "+n.serialno),this.internalOnDevicesChanged(),e(n)}.bind(this);n.serialno?
t(n.serialno):n.newSocket("shell:getprop ro.serialno",function(n){a(n,function(n)
{t(n)}.bind(this))}.bind(this))},h.prototype.tryDevice=function(e,t,i)
{this.adbDevices;var o=this.pendingDevices,s=this;function c(c){var
a=c.interfaceNumber;return!
o[a]&&(o[a]=e,console.log("claiming:",JSON.stringify(e),JSON.stringify(c)),chrome.u
sb.claimInterface(e,c.interfaceNumber,function()
{console.log("claimed:",JSON.stringify(chrome.runtime.lastError)),function(e,t,i)
{console.log("connecting");var o=new r(new n(e,t),i);console.log("sending
CNXN"),o.sendMessage(r.kCommandCNXN,r.ADB_PROTOCOL_VERSION,r.MAX_PAYLOAD,"host::"),
console.log("starting receive loop"),o.receiveMessages()}(e,c,function(n){if(!
n)return delete o[a],void
i();n.serialno=t,n.onOpenSocket=s.onOpenSocket,s.withAdbDevice(n,function(n){delete
o[a],i(n)})})}),!0)}chrome.usb.listInterfaces(e,function(n){if(!n)return
console.log("unable list
interfaces",JSON.stringify(chrome.runtime.lastError)),void(i&&i());console.log("got
interfaces",JSON.stringify(n));var t=!1;for(var o in
n)255==(o=n[o]).interfaceClass&&66==o.interfaceSubclass&&1==o.interfaceProtocol&&(t
|=c(o));t||chrome.usb.closeDevice(e)})},h.prototype.refreshDevice=function(n,e)
{chrome.usb.openDevice(n,function(t){if(!t)return console.log("unable to open
device",JSON.stringify(chrome.runtime.lastError)),void(e&&e());this.start(),this.tr
yDevice(t,n.serialNumber,function(t)
{t&&(t.usbDevice=n),e(t)})}.bind(this))},h.prototype.refresh=function()
{if(this.server){var n=d();if(!(this.server.lastRefresh&&this.server.lastRefresh>n-
1e4)){this.server.lastRefresh=n;var
e=chrome.runtime.getManifest().permissions.pop().usbDevices;$(e).each(function(n,e)
{var t=e.vendorId+"&"+e.productId;this.refreshing[t]||(this.refreshing[t]=!
0,chrome.usb.findDevices({productId:e.productId,vendorId:e.vendorId},function(n)
{var i=n.length;if(i)for(var o in
console.log("found:",e,n),n)console.log("trying:",n[o]),this.tryDevice(n[o],n[o].se
rialNumber,function(){--i||delete this.refreshing[t]}.bind(this));else delete
this.refreshing[t]}.bind(this)))}.bind(this))}}else console.log("adb server refresh
requested while server killed")},h.prototype.internalOnDevicesChanged=function()
{for(var n in this.clients)if((n=this.clients[n]).tracking){var
e=n.getDevicesString();e.length||(e="0000\n"),n.socket.write(o(e),function()
{})}},h.prototype.stop=function()
{this.server.destroy()},v.prototype.resolveTransport=function(n,e){if(e){var
t=this.server.adbDevices[e];return t||"device not found"}var
i=Object.keys(this.server.adbDevices);if(i>1)return"more than one
device";if(0==i)return"no devices connected";for(var o in
this.server.adbDevices)return
this.server.adbDevices[o]},v.prototype.write=function(n,e,i){e||(e="OKAY");var
r=t((n=o(n)).byteLength);r=o(e+r);var s=u(new Uint8Array(r),new
Uint8Array(n)).buffer;i||(i=function()
{this.socket.destroy()}.bind(this)),this.socket.write(s,i)},v.prototype.getDevicesS
tring=function(n){var e=(n=n||{}).longformDevices,t="";for(var i in
this.server.adbDevices)t+=(i=this.server.adbDevices[i]).serialno+"\tdevice",e&&("us
b"==i.transport.type?t+=" usb:"+i.transport.iface.interfaceNumber:t+="
tpcip:something",t+=" product:"+i.properties["ro.product.name"],t+="
model:"+i.properties["ro.product.model"],t+="
device:"+i.properties["ro.product.device"]),t+="\n";return
t},v.prototype.writeDevices=function(n,e)
{this.write(this.getDevicesString(n),null,e)},v.prototype.handlePayload=function(n)
{var s=(n=i(n)).split(":"),c=n;switch("host-
serial"==s[0]&&(s[0]="host",g=s.splice(1,1)
[0],Number.isInteger(parseInt(s[1]))&&(g+=":"+s.splice(1,1)
[0])),s.length>=2&&(c=s[0]+":"+s[1]),c)
{case"host:version":this.write(t(r.ADB_VERSION));break;case"host:devices-
l":case"host:devices":var a="host:devices-
l"==n;this.server.refresh(),this.writeDevices({longformDevices:a});break;case"host:
features":if("String"==(y=this.resolveTransport(n,g)).constructor.name)
{this.write(y,"FAIL");break}var h=y.properties.features;h||
(h=""),this.write(t(h));break;case"host:transport-usb":case"host:transport-
any":if("String"==(y=this.resolveTransport(n,g)).constructor.name)
{this.write(y,"FAIL");break}this.transport=y,this.socket.write(o("OKAY"),function()
{});break;case"host:kill":this.server.kill();break;case"host:disconnect":if(s.lengt
h>4){this.write("host:disconnect only takes 1
argument","FAIL");break}if(s.length>2)if((v=s[2]).length){var
u=5555;s.length>3&&(u=Number.parseInt(s[3]));var l=v+":"+u;
(f=this.server.adbDevices[l])&&"tcp"==f.transport.type&&f.destroy(),this.write("dis
connected");break}for(var f in
this.server.adbDevices)"tcp"==(f=this.server.adbDevices[f]).transport.type&&f.destr
oy();this.write("disconnected");break;case"host:connect":if(s.length<3)
{this.write("need more arguments for connect <host>[:<port>]","FAIL");break}var
v=s[2];u=5555;s.length>3&&(u=Number.parseInt(s[3])),Socket.connect({host:v,port:u},
function(n,t){if(!n)return console.error("connect failed"),this.write("unable to
connect to "+v+" "+u+": "+t,"FAIL"),this;var i=new r(new e(n),function(n)
{this.server.withAdbDevice(n,function(){var n="connected to
"+v+":"+u;console.log(n),this.write(n)}.bind(this))}.bind(this));i.onOpenSocket=thi
s.onOpenSocket,i.serialno=v+":"+u,n.onClose=function(){i.fatal("socket
closed")}.bind(this),i.sendMessage(r.kCommandCNXN,r.ADB_PROTOCOL_VERSION,r.MAX_PAYL
OAD,"host::"),i.receiveMessages()}.bind(this));break;case"host:track-
devices":this.tracking=d(),this.writeDevices({},function()
{});break;case"host:forward":var
m=s.join(":").substring(c.length+1).split(";"),w=m[0].split(":"),p=parseInt(w[1]);i
f("String"==(y=this.resolveTransport(n,g)).constructor.name)
{this.write(y,"FAIL");break}y.forwardPort({fromPort:p,to:m[1]}),this.socket.write(o
("OKAYOKAY"),function(){}.bind(this));break;default:var y;if(this.transport)return
void(y=this.transport).newSocket(n,function(n){n?
(this.socket.write(o("OKAY"),function()
{}),Socket.stream(n,this.socket)):this.socket.write(o("OKAY"),function()
{this.socket.destroy()}.bind(this))}.bind(this));if(n.startsWith("host:transport:")
){var g=n.substr("host:transport:".length);if(!(f=this.server.adbDevices[g]))return
void this.write("device not
found","FAIL");this.transport=f,this.socket.write(o("OKAY"),function()
{});break}console.log("unknown request: "+n),this.write("unknown command:
"+n,"FAIL");var
b=chrome.runtime.getManifest().name;chrome.notifications.create({type:"basic",iconU
rl:"/icon.png",title:b,message:b+"'s adb server encountered an unknown adb
command.\nYou may want to close "+b+" and start your adb binary
manually."})}this.receiveHeader()},v.prototype.receivePayload=function(n){var
e=parseInt(i(n),16);this.socket.read(e,this.handlePayload.bind(this))},v.prototype.
receiveHeader=function()
{this.socket.read(4,this.receivePayload.bind(this))},window.AdbDevice=r,window.AdbS
erver=h,window.AdbTcpTransport=e}(),function(){var n={};function e()
{}n.sendHostCommand=function(n,e)
{Socket.connect({host:"127.0.0.1",port:5037},function(r){if(r){var
s=n;n=t(n.length)+n,r.read(4,function(n){var
t=i(n);if("OKAY"!=t)return console.error("error in response to adb host
command",s,t),r.destroy(),void e();r.read(4,function(n){var t=i(n);0!
=(n=parseInt(t,16))&&"OKAY"!=t?r.read(n,function(n){e(r,n)}):e(r,new
ArrayBuffer(0))})}),r.write(o(n),function(){})}else e()})},n.devices=function(e)
{var t={};function o(n){var e=n,i=(n=n.replace("\t"," ")).indexOf(" ");if(-1!=i)
{var o,r=n.substring(0,i);for(n=n.substring(i).trim();o!=n;)o=n,n=n.replace(" ","
");var s={},c=n.indexOf(" ");-1==c&&(c=n.length);var
a,h=n.substring(0,c);for(n=n.substring(c+1);n.length&&-1!=(i=n.indexOf(":"));){var
u,l=n.substring(0,i),f=n.substring(i+1),d=f.indexOf(" "),v=f.indexOf(":");if(-
1==d||-1==v)u=f,n="";else for(;-1!
=d&&d<v;)u=f.substring(0,d),n=f.substring(d+1),d=f.indexOf("
",d+1);s[l]=u}a=s.model?s.model.replace("_","
"):r,t[r]={serialno:r,name:a,status:h,properties:e}}}n.sendHostCommand("host:device
s-l",function(n,r){if(n){n.destroy(),r=i(r),console.log("ADB devices:",r);var
s=(r=r.trim()).split("\n");for(var c in s)o(c=s[c]);console.log("parsed ADB
devices:",t),e(t)}else e()})},n.killServer=function(e)
{n.sendHostCommand("host:kill-server",function(n,t){n?
(n.destroy(),t=i(t),e&&e()):e()})},n.sendClientCommand=function(n,e){var
r=n.command,s=n.serialno;Socket.connect({host:"127.0.0.1",port:5037},function(n)
{if(n){n.read(4,function(s){if("OKAY"!=i(s))return n.destroy(),void e(null);var
c=r;c=t(c.length)+c,n.read(4,function(t){if("OKAY"!=i(t))return n.destroy(),void
e(null);e(n)}),n.write(o(c),function(){})});var c="host:transport:"+s;c=t(c.length)
+c,n.write(o(c),function(){})}else e()})},n.shell=function(e,t){var
i=e.command;e.serialno;n.getOrCreateSockFactory(e).newSocket("shell:"+i,function(n)
{n?a(n,function(n){t(n)}):t()})},n.forward=function(e,t){var i="host-
serial:"+e.serialno+":forward:"+e.from+";"+e.to;n.sendHostCommand(i,function(n,e)
{n&&n.destroy(),t(n,e)})},n.reverse=function(e,t){var
i="reverse:forward:"+e.from+";"+e.to;n.sendClientCommand({serialno:e.serialno,comma
nd:i},function(n,e){n?a(n,t):t()})},e.MKID=function(n,e,t,i){return
n.charCodeAt(0)|e.charCodeAt(0)<<8|t.charCodeAt(0)<<16|
i.charCodeAt(0)<<24},e.ID_RECV=e.MKID("R","E","C","V"),e.ID_SEND=e.MKID("S","E","N"
,"D"),e.ID_DONE=e.MKID("D","O","N","E"),e.ID_DATA=e.MKID("D","A","T","A"),e.DATA_MA
X=65536,n.pull=function(t,i){var
r,s=t.file,c=(t.serialno,t.fileEntry),a=t.socket;a||(a={write:function(n,e){r?
(r.onwriteend=e,r.write(new Blob([n]))):c.createWriter(function(t)
{r=t,a.write(n,e)})}});var h=new O;Socket.pump(h,a,function()
{i(c)}),n.getOrCreateSockFactory(t).newSocket("sync:",function(n){if(n){var t=new
ArrayBuffer(8),r=new DataView(t);r.setUint32(0,e.ID_RECV,!
0),r.setUint32(4,s.length,!0),n.write(t,function(){n.write(o(s),function()
{c()})})}else i();function c(){n.read(8,function(t){var o=new
DataView(t.buffer,t.byteOffset,t.byteLength),r=o.getUint32(0,!0);r!=e.ID_DATA?
(n.destroy(),r!=e.ID_DONE?i():h.dataReceived(null)):function(e)
{n.read(e,function(n){h.dataReceived(n),c()})}(o.getUint32(4,!
0))})}})},n.createSocketFactory=function(e){return{newSocket:function(t,i)
{n.sendClientCommand({serialno:e,command:t},i)}}},n.getOrCreateSockFactory=function
(e){return e.socketFactory||n.createSocketFactory(e.serialno)},n.push=function(t,i)
{var
r=t.file,s=(t.serialno,t.socket);n.getOrCreateSockFactory(t).newSocket("sync:",func
tion(n){if(n){var t=new ArrayBuffer(8),c=new
DataView(t),a=r+",0644";c.setUint32(0,e.ID_SEND,!0),c.setUint32(4,a.length,!
0),n.write(t,function(){n.write(o(a),function(){function t(){s.read(function(i)
{if(i.byteLength>e.DATA_MAX){var
o=i.subarray(e.DATA_MAX);i=i.subarray(0,e.DATA_MAX),s.unshift(o)}!function(i){var
o=new ArrayBuffer(8),r=new DataView(o);r.setUint32(0,e.ID_DATA,!
0),r.setUint32(4,i.byteLength,!0),n.write(o,function(){var e=i.buffer;
(i.byteOffset||i.length!
=e.byteLength)&&(e=e.slice(i.byteOffset,i.byteOffset+i.byteLength)),n.write(e,funct
ion(){t()})})}(i)})}s.onClose=function(){var t=new ArrayBuffer(8),o=new
DataView(t);o.setUint32(0,e.ID_DONE,!0),o.setUint32(4,0,!0),n.write(t,function()
{n.read(8,function(){i()})})},t()})})}else i()})},window.Adb=n}(),function()
{function n(n,e)
{this.transport=n,this.sockets={},this.currentSocketId=0,this.maxPayload=e||
AdbDevice.MAX_PAYLOAD}n.prototype.start=function(n){var e=o(n,void 0,!
0);this.sendMessage(AdbDevice.kCommandCNXN,AdbDevice.ADB_PROTOCOL_VERSION,this.maxP
ayload,e),this.receiveMessages()},n.prototype.fatal=function(n){console.log("fatal
error",n);var e=this.onClose;e&&(delete
this.onClose,e())},n.prototype.sendMessage=AdbDevice.prototype.sendMessage,n.protot
ype.receiveMessages=AdbDevice.prototype.receiveMessages,n.prototype.onReceiveMessag
e=AdbDevice.prototype.onReceiveMessage,n.prototype.handleMessage=AdbDevice.prototyp
e.handleMessage,n.prototype.handleUnknown=AdbDevice.prototype.handleUnknown,n.proto
type.newSocket=AdbDevice.prototype.newSocket,n.prototype.newAdbSocket=AdbDevice.pro
totype.newAdbSocket,n.prototype.destroy=AdbDevice.prototype.destroy,n.prototype.onO
penSocket=function(n,e){if(this.openSocket){var t=+
+this.currentSocketId,o=this.newAdbSocket(t);o.remoteId=e,this.sockets[t]=o,this.se
ndMessage(AdbDevice.kCommandOKAY,t,e),this.openSocket(i(n),o)}},window.AdbDaemon=n}
(),function(){function n(n,e,t,i)
{$.ajax({url:n,dataType:"binary",responseType:"arraybuffer",success:function(n){var
o=new O(new Uint8Array(n)),r="/data/local/tmp/apk"+(new Date).getTime()
+".apk";Adb.push({serialno:e,file:r,socket:o},function(){t?Adb.shell({command:"pm
install -i "+t+" -r "+r,serialno:e},i):Adb.shell({command:"pm install -r
"+r,serialno:e},i)})},error:function(n){console.error("error fetching
apk",n),i()}})}window.AdbUtils={runMain:function(n,e,t,i,o){o||
(o=Adb.shell),Adb.shell({command:"ls -l
/system/bin/app_process*",serialno:n},function(r){var
s="/system/bin/app_process";r&&-1!
=r.indexOf("app_process32")&&(s+="32"),o({command:'sh -c "CLASSPATH='+e+" "+s+"
/system/bin "+t+'"',serialno:n},i)})},installApk:function(e,t,i){return
n(e,t,null,i)},installApkWithInstaller:n,getApkPath:function(n,e,t)
{Adb.shell({command:"pm path "+e,serialno:n},function(n){if(""!=n&&n){var
e=n.match(/package:\/.*?[\r\n]/);e&&e.length?
(n=(n=e[0]).replace("package:","").trim(),t(n)):t(null)}else t(null)})}}}(),
(p=function(n){this.authorization=n}).prototype.shorten=function(n,e)
{$.ajax({type:"POST",url:"https://www.googleapis.com/urlshortener/v1/url?
key="+this.authorization,data:JSON.stringify({longUrl:n}),contentType:"application/
json",dataType:"json",success:function(n){e(n.id)}})},window.Googl=p,g=!0,b=!
0,k="Account Management",T.prototype.refresh=function(n,e)
{console.log("interactive",e),this.refreshInternal(n,e).async()},T.prototype.refres
hInternal=function*(n,t){var i,o,r,s=function(){e(function(){if(this.t()){var
n,e=chrome.app.window.getAll().filter(function(n){return
n&&"purchase"==n.id});e&&e.length,null!=(n=e[0])&&(n.close(),m("Vysor subscription
is active. Thank you for your support!"))}}.bind(this)),this.globalRefresh?
this.globalRefresh():console.error("no global refresh?"),i||(i=!
0,n&&n(this.t()))}.bind(this),c=!
1;window.chrome&&window.chrome.runtime&&window.chrome.runtime.connect||(c=!0);var
a=function(n,e){return!!e.licensed&&(n!=e.email?(console.log("email mismatch"),!1):
(console.log("enterprise license retrieved"),!0))}.bind(this),h=function(n,e){if(0!
=e.sandbox)return console.log("sandbox mismatch"),!1;if(n!=e.buyer_id)return
console.log("id mismatch"),!1;if("koushd@gmail.com"!=e.seller_id)return
console.log("seller mismatch"),!1;var t=!1;return
e.subscriptions&&$.each(e.subscriptions,function(n,e){console.log("subscription
found",e),e.remote_plan_id.startsWith("vysor")?
e.subscription_active&&(console.log("clockwork subscription
retrieved"),t=e.license_first_retrieved):console.log("skipping non-vysor
subscription")}.bind(this)),$.each(e.orders,function(n,e){console.log("purchase
found",e),e.product_id.startsWith("vysor")?e.is_purchased&&(console.log("clockwork
license retrieved"),t=e.order_date):console.log("skipping non-vysor
purchase")}.bind(this)),t}.bind(this),u=function(n){$.each(n,function(n,e)
{console.log("subscription status",e),"ACTIVE"==e.state&&(console.log("chrome
license retrieved"),g=!0)}.bind(this))}.bind(this),l=function*(){if(r&&!t)return
console.log("Skipping enterprise license server check."),void console.log("Use
Retrieve License from the purchase page to force refresh.");console.log("checking
chrome enterprise licenses");var n=yield D(!1,yield);if(!n)return
chrome.runtime.lastError,void console.error("No auth token for enterprise
licensing");try{var e=yield chrome.identity.getProfileUserInfo(yield);if(!A)return
void console.log("unable to retrieve user info for enterprise");e.id;var
i=e.email;try{e=yield $.ajax({url:"https://billing.vysor.io/license",headers:
{Authorization:"Bearer "+n},dataType:"json",success:yield S,error:yield Error});var
o=JSON.parse(e.signed_data);if(yield
chrome.storage.local.set({cachedEnterpriseLicense:e},yield),!a(i,o))return void
console.log("No enterprise license found on
server");y="https://billing.vysor.io",k="Enterprise Account
("+o.licensing_accounts[0]+")",g=!0,b=!0,s()}catch(e){yield
chrome.identity.removeCachedAuthToken({token:n},yield),console.error("Error
communicating with vysor enterprise",e)}}catch(e){yield
chrome.identity.removeCachedAuthToken({token:n},yield),console.error("Unable to get
email for enterprise",e)}}.bind(this),f=function*(){if(o&&!t)return
console.log("Skipping clockwork license server check."),void console.log("Use
Retrieve License from the purchase page to force refresh.");console.log("checking
clockwork purchases");var n=yield D(!1,yield);if(!n)return
chrome.runtime.lastError,void console.error("No auth token for clockwork
billing");try{var e=yield chrome.identity.getProfileUserInfo(yield);if(!A)return
void console.log("unable to retrieve user info for clockwork");var
i=e.id,r="https://billing.clockworkmod.com/api/v1/purchase/koushd@gmail.com?
sandbox=false&nonce="+Date.now();try{e=yield
$.ajax({url:r,dataType:"json",headers:{Authorization:"Bearer "+n},error:yield
Error,success:yield S});var c=JSON.parse(e.signed_data);if(yield
chrome.storage.local.set({cachedClockworkLicense:e},yield),!h(i,c))return void
console.log("no clockwork license found on
server");y="https://billing.clockworkmod.com",g=!0,b=!0,s()}catch(n)
{console.error("error requesting purchases",n)}}catch(e){yield
chrome.identity.removeCachedAuthToken({token:n},yield),console.error("Unable to get
buyer id for clockworkbilling",e)}}.bind(this),d=function*(){if(!c){var
n;console.log("checking chrome store purchases");try{n=yield
google.payments.inapp.getPurchases({parameters:{env:"prod"},success:yield
S,failure:yield Error})}catch(n){if(console.error("Failed to query license from
chrome store.",n),!t)return console.log("Skipping Chrome license server fallback
check."),void console.log("Use Retrieve License from the purchase page to force
refresh.");console.log("Falling back to server proxied query.");try{yield this.i(!
1,yield),yield*v()}catch(n){console.error("failed to do fallback server
check",n)}return}u(n.response.details),this.t()?
(y="https://payments.google.com/payments/home#subscriptionsAndServices",s(),console
.log("Caching Vysor license."),yield this.i(!
1,yield),this.o()&&s()):console.log("no chrome license found on
server")}}.bind(this),v=function*(){if(!c){console.log("checking cached chrome
license");var n=yield
chrome.storage.local.get("cachedLicense",yield);if(n)if(n.cachedLicense)if(A){var
e=yield C("AQAB","vMGBBmLcMO4lOmg-YAHq2DjZKHTaW-
xs9KPNXU_zKJ7ZhFhWH3I6skF9ZO8lKeXOSwVEIW4HVMa7m16S6WTrUw",n.cachedLicense.signed_da
ta,n.cachedLicense.signature,yield);if(e)console.error("error verifying cached
signature",e);else{var
t=JSON.parse(n.cachedLicense.signed_data),i=Date.now();if($.each(t.payments,functio
n(n,e)
{"ACTIVE"==e.state&&(i=Math.min(i,e.createdTime))}.bind(this)),t.date>Date.now())co
nsole.log("cached license date from future?");else{var o,r=(new Date-new
Date(i))/1e3/60/60/24,a=(o=r<14?4:Math.min(30,4+(r-
14)/7))/2;if(t.date+24*o*60*60*1e3<Date.now())console.log("cached license is
expired.");else if(A.id==t.userinfo.id)if(u(t.payments),this.t())
{if(y="https://payments.google.com/payments/home#subscriptionsAndServices",console.
log("cached license is valid for "+(t.date+24*o*60*60*1e3-Date.now())/36e5+"
hours"),b=!0,s(),t.date+24*a*60*60*1e3<Date.now()){console.log("Refreshing cached
license");try{yield this.i(!1,yield)}catch(e){console.warn("Failed to re-cache
license.",e)}}}else console.log("no chrome license found in cache");else
console.log("id mismatch")}}}else console.log("unable to retrieve user info for
cache");else console.log("no cached chrome license found");else
console.error("storage access
failed?",chrome.runtime.lastError)}}.bind(this),w=function*(){console.log("Checking
cached Clockwork license.");var n=yield
chrome.storage.local.get("cachedClockworkLicense",yield);if(n)if(n.cachedClockworkL
icense)if(A){var e=A.id,t=yield C("AQAB","vMGBBmLcMO4lOmg-YAHq2DjZKHTaW-
xs9KPNXU_zKJ7ZhFhWH3I6skF9ZO8lKeXOSwVEIW4HVMa7m16S6WTrUw",n.cachedClockworkLicense.
signed_data,n.cachedClockworkLicense.signature,yield);if(t)console.error("Error
verifying cached clockwork signature",t);else{var
i=JSON.parse(n.cachedClockworkLicense.signed_data),r=h(e,i);if(!r)return
console.log("No Clockwork license found in cache."),void(o=!
0);y="https://billing.clockworkmod.com";var c,a=(new Date-new
Date(r))/1e3/60/60/24,u=(c=a<14?4:Math.min(30,4+(a-
14)/7))/2;i.timestamp+24*c*60*60*1e3<Date.now()?console.log("Cached Clockwork
license is expired. Requires server check."):i.timestamp>Date.now()?
console.error("Cached Clockwork license date from future?"):(g=!
0,console.log("Cached Clockwork license is valid for "+(i.timestamp+24*c*60*60*1e3-
Date.now())/36e5+" hours"),b=!0,s(),i.timestamp+24*u*60*60*1e3<Date.now()&&(o=!
1,yield*f()))}}else console.error("Unable to retrieve user info for cached
Clockwork license.");else console.log("Cached Clockwork payload not found.");else
console.error("storage access
failed?",chrome.runtime.lastError)}.bind(this),p=function*(){console.log("Checking
cached enterprise license.");var n=yield
chrome.storage.local.get("cachedEnterpriseLicense",yield);if(n)if(n.cachedEnterpris
eLicense)if(A){var e=yield
C("AQAB","hDuGsIhbjLYXteQX3F3KNriQHwUSZurS5voCkdpA1733A65pqtGOrk9g_yLiF94_vSK0VmL-
4stq7WAYEbn6nw",n.cachedEnterpriseLicense.signed_data,n.cachedEnterpriseLicense.sig
nature,yield);if(e)console.error("Error verifying cached enterprise
signature",e);else{var t=JSON.parse(n.cachedEnterpriseLicense.signed_data);if(!
a(A.email,t))return r=!0,void console.log("No Enterprise license found in
cache.");t.timestamp+3456e5<Date.now()?console.log("Cached Enterprise license is
expired. Requires server check."):t.timestamp>Date.now()?console.error("Cached
Enterprise license date from future?"):(y="https://billing.vysor.io",k="Enterprise
Account ("+t.licensing_accounts[0]+")",g=!0,console.log("Cached Enterprise license
is valid for "+(t.timestamp+3456e5-Date.now())/36e5+" hours"),b=!
0,s(),t.timestamp+1728e5<Date.now()&&(r=!1,yield*l()))}}else console.error("Unable
to retrieve user info for cached Clockwork license.");else console.log("Cached
Enterprise payload not found.");else console.error("storage access
failed?",chrome.runtime.lastError)}.bind(this);if(this.t())s();else{console.log("st
arting license check");var A=yield chrome.identity.getProfileUserInfo(yield);A?
console.log("user info",A):console.log("unable to retrieve user
info"),yield*p(),this.t()||(yield*w(),this.t()||(yield*v(),this.t()||
(yield*l(),this.t()||(yield*f(),this.t()||(yield*d(),this.t()||
s())))))}},T.prototype.i=function(n,e){console.log("caching chrome
license"),D(n,function(t){if(!t)return chrome.runtime.lastError,n&&m("Unable to get
auth token: "+chrome.runtime.lastError),console.error("Unable to get auth token
while caching
license",chrome.runtime.lastError),void(e&&e(chrome.runtime.lastError));
$.ajax({type:"post",url:"https://billing.clockworkmod.com/api/v1/verify/google/kous
hd@gmail.com",data:
{token:t,item:chrome.runtime.id,version:chrome.runtime.getManifest().version},dataT
ype:"json",success:function(n){console.log("chrome license cached"),b=!
0,chrome.storage.local.set({cachedLicense:n},e)}.bind(this),error:function(n,i)
{console.error("unable to cache
license",i),chrome.identity.removeCachedAuthToken({token:t},function()
{e&&e(i)})}})}.bind(this))},T.prototype.t=function(){return
g},T.prototype.o=function(){return b},T.prototype.getManageData=function()
{return{managementUrl:y,managementText:k}},T.prototype.startPurchase=function()
{chrome.app.window.create("purchase.html",{id:"purchase",innerBounds:
{minWidth:800,minHeight:860}},function(n)
{this.refresh(),n.contentWindow._rlm=function(n)
{chrome.storage.local.remove(["cachedLicense","cachedClockworkLicense","cachedEnter
priseLicense"],function(){this.refresh(n,!
0)}.bind(this))}.bind(this)}.bind(this))},E.prototype.openSocket=function(n,e){if(!
this.onOpenSocket||!this.onOpenSocket(n,e))if("properties"!
=n)this.adbSocketFactory.newSocket(n,function(t){if(!t)return console.log("unable
to execute adb proxy command?",n),void e.destroy();Socket.stream(t,e,function()
{})});else{var t=this.properties;e.write(o(t),function(){console.log("sent
properties",t),e.destroy()})}};console.log("Vysor
version",chrome.runtime.getManifest().version),console.log(navigator.userAgent),con
sole.log("Electron",isElectron()),console.log("Date",new Date);var V,P,R,x=new
AdbServer({start:!
1}),M={},j={},q={},L=analytics.getService("vysor_app").getTracker("UA-4956323-
6");if(isElectron()){var
J=L;L={sendEvent:J.sendEvent.bind(J),sendAppView:J.sendAppView.bind(J)};const{scree
n:n}=require("electron");console.log("getAllDisplays",n.getAllDisplays()),console.l
og("getPrimaryDisplay",n.getPrimaryDisplay())}var _,K,F,z=new T,H="Chrome GCM
Service is unavailable. Try restarting Chrome?",Y=new HttpServer;function W(n)
{n.contentWindow._lm={_il:z.t(),_ilc:z.o(),_cl:z.i.bind(z),_md:z.getManageData(),re
fresh:z.refresh.bind(z),startPurchase:z.startPurchase.bind(z)},n.contentWindow._rl&
&n.contentWindow._rl()}function X(n,e){if(R){var
t=R.contentWindow.shortModal;t&&t(n,e)}}function G()
{R&&R.contentWindow.updateVysorShareServer&&R.contentWindow.updateVysorShareServer(
P)}function Q(n,e){var t=rn(n);console.log(n,t,"status",e);var
i=chrome.app.window.get(t);i&&i.contentWindow.updateWindowStatusText&&i.contentWind
ow.updateWindowStatusText(e)}function Z(n,e)
{Q(n,"Connecting..."),AdbUtils.getApkPath(n,"com.koushikdutta.vysor",function(t){t?
AdbUtils.runMain(n,t,"com.koushikdutta.vysor.ProtocolVersionMain",function(n){var
i=n.match(/vysor-io-.*?[\r\n]/);i&&i.length?
((n=i[0])&&(n=n.trim()),console.log("protocol version: "+n),e("vysor-io-71"!=n?
null:t)):e(null)}):e()})}function nn(n,e){function t(t){var
i=Math.round(Math.random()*(1<<30)).toString(16),o="echo -n "+i+" >
/data/local/tmp/vysor.pwd ; chmod 600
/data/local/tmp/vysor.pwd";AdbUtils.runMain(n,t,"com.koushikdutta.vysor.Main
password="+i+" keyboard="+V,function(t){Adb.shell({serialno:n,command:'sh -c
"'+o+'"'},function(n){Socket.eat(t),e(i)})},function(n,e)
{n.command="shell:"+n.command,Adb.sendClientCommand(n,e)})}Q(n,"Connecting...");rn(
n);Z(n,function(e){if(!e)return console.log("uninstalling old apk if exists"),void
Adb.shell({command:"pm uninstall com.koushikdutta.vysor",serialno:n},function(e)
{console.log("uninstall result",e),console.log("installing apk"),function(n,e)
{Q(n,"Installing Vysor APK..."),AdbUtils.installApkWithInstaller("/Vysor-
release.apk",n,"com.android.vending",e)}(n,function(e){Z(n,function(i){if(!i)return
e||(e=""),m("Error installing APK:\n"+e.trim()),void
en(n);t(i)})})});t(e)})}function en(n){var
e=rn(n),t=chrome.app.window.get(e);t&&t.close()}function tn(n,e,t){isElectron()?
(console.log("adb client socket factory
path"),n.contentWindow.adbSocketFactory=null,n.contentWindow.adbSocketFactoryFactor
y={type:"adb-client",arguments:{serialno:e}}):M[e]?(console.log("vysor
socket fast path"),n.contentWindow.adbSocketFactory=M[e]):x.isRunning()?
(console.log("adb server socket
path"),n.contentWindow.adbSocketFactory=x.adbDevices[e]):(console.log("adb client
socket
path"),n.contentWindow.adbSocketFactory=Adb.createSocketFactory(e)),W(n),n.contentW
indow.openList=dn,n.contentWindow.password=t,Y&&Y.socket&&(n.contentWindow.httpPort
=Y.socket.localPort),n.contentWindow.device=M[e]||
In[e],n.contentWindow.tracker=L}function on(){setTimeout(function()
{chrome.app.window.getAll().length||chrome.runtime.reload()},5e3)}function rn(n)
{var e=n;return M[n]&&M[n].id?e=M[n].id:In[n]&&In[n].id?
e=In[n].id:Nn[n]&&(e=Nn[n]),e}function sn(n,e,t){wn();var
i=rn(n),o=chrome.app.window.get(i);if(o)return o.show(),e&&nn(n,function(e)
{tn(o,n,e),o.contentWindow.connectionReady()}),void(t&&t(o));chrome.app.window.crea
te("screen.html",{id:i,innerBounds:{width:576,height:1024}},function(e){var
i;e.onClosed.addListener(i=function()
{e.onClosed.removeListener(i),on(),e.contentWindow.h264Socket&&(console.log("cleani
ng up h264
socket"),e.contentWindow.h264Socket.destroy(),e.contentWindow.h264Socket=null),e.co
ntentWindow.inputWebSocket&&(console.log("cleaning up input
websocket"),e.contentWindow.inputWebSocket.close(),e.contentWindow.inputWebSocket=n
ull)}),tn(e,n,null),e.contentWindow.onload=function(){t&&t(e),In[n]?
nn(n,function(t){tn(e,n,t),e.contentWindow.connectionReady()}):console.log("Vysor
requested for",n,"which is not available yet")}})}function cn()
{P=null,K&&K.stopListen("share"),G()}function an(n){var
e=q[n];e&&e.gcmConn.destroy()}function hn(n,e,t){var i=q[n];if(i&&i.devices[e]){var
o;i.gcmConn.gcmConns[e]&&i.gcmConn.gcmConns[e].destroy();var
r=i.gcmConn.gcmConns[e]={id:e,farm:!0,newSocket:function(n,t){o||
i.gcmConn.newSocket(e+":"+n,t)},destroy:function(){o=!
0,i.gcmConn.gcmConns[e]==r&&delete i.gcmConn.gcmConns[e],delete
In[r.serialno],i.gcmConn.newSocket("close:"+e,function(n){n&&n.destroy()});var
n=r.onClose;n&&(delete r.onClose,n()),qn()}};vn(e,function(n)
{n(r)},t),qn()}}function un(n,e,t){function i(n){t&&t(null,n)}var o=(n=new
URL(n)).hash.replace("#","");
$.ajax({url:"https://billing.vysor.io/gcm/"+o,dataType:"json",success:function(n)
{K?
K.connect({senderId:"64148182473",registrationId:n.registration,port:"share"}).then
(function(r){L.sendEvent("connected-device-farm");var
h,u=q[o];u&&u.gcmConn.destroy();var l=q[o]={info:n,gcmConn:r};function f()
{r.newSocket("devices:",function(n){a(n,function(n){var
e=JSON.parse(n),t=e.devices,i=e.sharedDevices;l.devices?
($.each(Object.keys(t),function(n,e){delete l.devices[e]}),
$.each(Object.keys(l.devices),function(n,e){var
t=r.gcmConns[e];t&&t.destroy()}),l.devices=t):l.devices=t,l.sharedDevices=i,qn()})}
)}r.gcmConns={},r.openSocket=function(n,o){if(n.startsWith("challenge:"))
{console.log("received challenge",n);var a=n.split(":")[1];
$.ajax({type:"post",url:"https://billing.vysor.io/verifyauth",headers:
{Authorization:"Bearer "+e},data:{nonce:a},dataType:"json",success:function(n)
{_=JSON.parse(n.signed_data),console.log("sending challenge
response",n),s(o,n,function(){c(o,function(n){if(o.destroy(),"ok"==n)return
f(),void(t&&t(l.info));i("Access denied: "+n)})})},error:function(n,e){i("Unable to
verify identity."),o.destroy()}})}else if(n.startsWith("close:")){o.destroy();var
u=n.split(":")[1],d=r.gcmConns[u];if(!d)return void console.log("can't close
unknown subconn");d.destroy()}else n.startsWith("tracker:")?(console.log("got
tracker socket"),h=o,function n(){h.read(function(){f(),n()})}()):(console.log("got
unknown socket request",n),o.destroy())},r.onClose=function(){q[o]==l&&delete q[o],
$.each(Object.keys(r.gcmConns),function(n,e){var
t=r.gcmConns[e];t&&t.destroy()}),qn()},console.log("Connection to device farm
established",r)}):i(H)},error:function(n,e){m("Unable to find server:
"+e)}})}function ln(n,e){function t(n){qn(),e?e(null,n):m(n)}function i()
{qn(),e&&e(P)}cn(),D(n,function(n){if(n)if(K){var
e;K.onRegistrationIdChanged=u,chrome.storage.local.get(["lastDeviceFarmRegistration
Id","lastDeviceFarmServerId"],function(n)
{if(n&&n.lastDeviceFarmRegistrationId==K.registrationId&&n.lastDeviceFarmServerId)r
eturn console.log("device farm registration unchanged, not registering with
server."),P="https://vysor.clockworkmod.com/server#"+n.lastDeviceFarmServerId,void
i();u()});var r,a=[];K.listen("share",function(n){var
e,t,i,o={},u=Math.round(Math.random()*(1<<30)).toString(16)+Math.round(Math.random(
)*(1<<30)).toString(16);n.onClose=function(){var e=a.indexOf(n);-1!
=e&&a.splice(e,1),n.trackerSocket&&(n.trackerSocket.destroy(),delete
n.trackerSocket),$.each(Object.keys(o),function(n,e)
{o[e].destroy()})},n.newSocket("challenge:"+u,function(o){if(!o)return
console.error("challenge socket failed"),void n.destroy();c(o,function(r)
{console.log("received challenge response",r);var c=JSON.parse(r);function h(n)
{n=n||"fail",console.log("Remote user failed to authorize",n),s(o,n,function()
{o.destroy()})}C("AQAB","hDuGsIhbjLYXteQX3F3KNriQHwUSZurS5voCkdpA1733A65pqtGOrk9g_y
LiF94_vSK0VmL-4stq7WAYEbn6nw",c.signed_data,c.signature,function(r){function l()
{function r(){a.push(n),e=!0,s(o,"ok",function(){o.destroy()}),m("Vysor is sharing
Android devices with "+t.name,i),Adb.sendHostCommand("host:track-
devices",function(e){e?n.newSocket("tracker:",function(t){if(!t)return
e.destroy(),void console.error("unable to open remote
tracker");n.trackerSocket=t,Socket.stream(t,e)}):console.error("unable to track adb
devices",chrome.runtime.lastError)})}var c,u;c=t.email,u=function(n,e)
{if(n)r();else if(e){var
o=chrome.runtime.getManifest().name;chrome.notifications.create({type:"basic",iconU
rl:i,title:o,message:t.name+" is requesting access to Vysor shared Android
devices.",buttons:[{title:"Allow"},{title:"Deny"}]},function(n){var e,i=function(t)
{t==n&&(chrome.notifications.onClosed.removeListener(i),chrome.notifications.onButt
onClicked.removeListener(o),e||h("Denied by user."))},o=function(i,o)
{i==n&&(chrome.notifications.clear(i),e=!0,0==o?(N(t.email,function()
{G()}),r()):h("Denied by
user."))};chrome.notifications.onClosed.addListener(i),chrome.notifications.onButto
nClicked.addListener(o)})}else h("Denied by
policy.")},chrome.storage.local.get(["whitelist","serverMode"],function(n){if(1!
=n.serverMode){if(2!=n.serverMode)return
n.whitelist&&"Array"==n.whitelist.constructor.name?void u(-1!
=n.whitelist.indexOf(c),!0):void u(!1,!0);D(!1,function(n){if(!n)return
console.error("unable to get token for vysor enterprise whitelist check"),void u(!
1);$.ajax({type:"get",url:"https://billing.vysor.io/whitelist",headers:
{Authorization:"Bearer "+n},data:{email:c},error:function(){console.error("failure
checking vysor enterprise whitelist",arguments),u(!1)},success:function(n)
{n.whitelist||console.error("access denied to",c,n),u(n.whitelist,!1)}})})}else u(!
0)})}r?h("Identify signature verification failed."):
(t=JSON.parse(c.signed_data)).nonce==u?t.picture?A(t.picture,function(n){i=n,l()}):
(i="/icon.png",l()):h("Mismatched nonce in
authentication.")})})}),n.openSocket=function(i,s)
{if(e)if("devices:"==i)r=v(r,s,500,function(n){B(function(e)
{Adb.devices(function(t){t||(t={}),$.each(Object.keys(t),function(n,i){M[i]&&delete
t[i],I(e[i]),e[i]&&e[i].friendlyName&&(t[i].name=e[i].friendlyName)});var i={};
$.each(Object.keys(j),function(n,e){i[e]={userInfo:j[e].userInfo}}),$
(n).each(function(n,e){h(e,{devices:t,sharedDevices:i},function()
{e.destroy()})})})})});else if(i.startsWith("close:")){s.destroy();var
c=i.split(":")[1];(u=o[c])&&u.destroy()}else{var a=i.indexOf(":");if(-1==a)return
console.error("unexpected command received by device farm server"),void
s.destroy();var u;c=i.substring(0,a);if(!In[c]){if(-
1==(a=i.indexOf(":",a+1)))return void s.destroy();if(c=i.substring(0,a),!
In[c])return void console.error("request for unknown device",c)}if(!(u=o[c])){var
f=Adb.createSocketFactory(c);(u=o[c]=new E(f,In[c],{})).destroy=function()
{try{n.newSocket("close:"+c,function(n){n&&n.destroy()})}catch(n){}var
e=j[c];e&&(e.userInfo==t&&delete e.userInfo,e.gcmConn==this&&delete
e.gcmConn,e.key||e.gcmConn||delete j[c]);var i=this.onClose;i&&(delete
this.onClose,i()),l()}.bind(u)}var d=j[c];d||(d=j[c]={}),d.gcmConn!
=u&&(pn(c),d.gcmConn=u,d.userInfo=t,j[c]=d),l();var
m=i.substring(a+1);u.openSocket(m,s)}else s.destroy()}})}else t(H);else t("Unable
to get Auth Token.");function u(){console.log("registering vysor share server"),
$.ajax({type:"post",url:"https://billing.vysor.io/gcm",headers:
{Authorization:"Bearer "+n},data:
{registration:K.registrationId},dataType:"json",success:function(n)
{console.log("vysor share
server",n),chrome.storage.local.set({lastDeviceFarmRegistrationId:K.registrationId,
lastDeviceFarmServerId:n.id}),P="https://vysor.clockworkmod.com/server#"+n.id,i()}.
bind(this),error:function(n,e){cn(),t("Unable to register server: "+e)}})}function
l(){e=v(e,null,500,function(){$.each(a,function(n,e)
{e.trackerSocket&&e.trackerSocket.write(o("0000\n"),function()
{})}),qn()})}})}function fn(n){V=n}function dn(){R?
R.focus():chrome.app.window.create("list.html",{id:"list",innerBounds:
{width:768,height:868,minWidth:768,minHeight:868}},function(n)
{(R=n).contentWindow.openList=dn,W(R),R.contentWindow.disconnectSharedDevice=xn,R.c
ontentWindow.toggleShare=Mn,R.contentWindow.unshareDevice=yn,R.contentWindow.quietS
erial=Rn,R.contentWindow.openWindow=sn,R.contentWindow.closeWindow=en,R.contentWind
ow.createDeviceFarmConnection=hn,R.contentWindow.destroyDeviceFarmConnection=an,R.c
ontentWindow.adbServer=x,R.contentWindow.tracker=L,R.contentWindow.startWireless=jn
,R.contentWindow.startDeviceFarm=ln,R.contentWindow.stopDeviceFarm=cn,R.contentWind
ow.updateKeyboard=fn,R.contentWindow.onload=function()
{W(R),G(),qn()},R.onClosed.addListener(function(){R=null,on()})})}function
vn(n,e,t){x.start();var o=new
Server;o.listen({port:0,address:"127.0.0.1"},function(n){o.destroy();var i=new
AdbDaemon(new AdbTcpTransport(n));e(function(n){L.sendEvent("connected-shared-
device");var
e="127.0.0.1:"+o.localPort;n.serialno=e,n.id||
(n.id=e),M[e]=n,console.log("connected gcm socket"),n.openSocket=function()
{console.log("got a new socket? this should not
happen..."),n.destroy()},i.onClose=n.onClose=function(){delete
M[e],i.destroy(),n.destroy()},n.onClose=function(){delete
M[e],i.destroy(),n.destroy(),m("Disconnected from shared Android
device.")},i.openSocket=function(e,t){n.newSocket(e,function(n)
{Socket.stream(t,n,function(){})})},n.newSocket("properties",function(o)
{a(o,function(o){var r=AdbDevice.parseConnectionPayload(o);n.name=n.name||
r["ro.product.model"].replace("_"," "),i.start(o),console.log("got
properties",o),t(e)})})})}.bind(this),function(e){if(e)console.log("adb daemon
failed to listen: "+e);else{var t="127.0.0.1:"+o.localPort;M[t]={id:n||
t,destroy:function()
{}},console.log("mapping",t,n),qn(),Adb.sendHostCommand("host:connect:"+t,function(
n,e){n&&(n.destroy(),e=i(e),console.log("adb connect
result",e))})}}.bind(this))}function mn(n,e){if(m("Vysor is connecting to a remote
Android device"),R&&R.show(),console.log("attempting to connect to shared
device",n),K){var t=new
URL(n),i=d("senderId",t),o=d("registrationId",t),r=d("channel",t);i||
(i="64148182473"),vn(null,function(n)
{K.connect({senderId:i,registrationId:o,port:r}).then(n)},e)}else
X(null,H)}function wn(){chrome.runtime.requestUpdateCheck(function(n,e)
{console.log("update
check",arguments),"update_available"==n&&(Tn=v(Tn,null,1e4,function(){var
n=chrome.runtime.getManifest().name;chrome.notifications.create("reload",
{type:"basic",iconUrl:"/icon.png",title:n,message:"There is an update available for
Vysor.",buttons:[{title:"Reload"}]})}))})}function pn(n){var
e=j[n];if(e&&e.gcmConn){var t=e.gcmConn;delete e.gcmConn,t.destroy()}}function
yn(n){pn(n),delete j[n],qn()}function gn(n,e){var t=In[n];if(K){var
i=Math.round(Math.random()*(1<<30)).toString(16);j[n]||
(j[n]={}),j[n].key=i,qn();var o="https://vysor.clockworkmod.com/redirect/?
registrationId="+encodeURIComponent(K.registrationId)
+"&channel="+i;console.log(o),K.listen(i,function(e){L.sendEvent("shared-
device");var o=j[n];if(!o||o.key!=i)return e.destroy(),void console.log("device is
no longer being
shared.");o.gcmConn&&o.gcmConn.destroy(),o.gcmConn=e,o.userInfo={name:"Someone"},qn
(),console.log("accepted gcm socket"),new
E(Adb.createSocketFactory(n),t,e).onOpenSocket=function(e,t)
{if("webstart"==e)return nn(n,function(n){s(t,n,function(){console.log("sent
password",n),t.destroy()})}),!0}});var r="https://tu3ph.app.goo.gl/?
ad=0&apn=com.koushikdutta.inkwire&link="+encodeURIComponent(o);e(r)}else
e&&e(null,H)}function bn(n){return function(){var e=arguments;(F||
(console.log("creating persistent gcm connection"),F=new Promise(function(n,e)
{GcmRtcManager.start({3505780036:"AIzaSyDt0GimPRhk8_d_4XjOYzQUn50UkvXhMtE",64148182
473:"AIzaSyDd7k1v017osyYbIC92fyf-36s3pv0z73U"},{iceServers:[{urls:
["turn:n0.clockworkmod.com","turn:n1.clockworkmod.com"],username:"foo",credential:"
bar"}]},function(e){if(K=e,console.log("persistent gcm connection created",null!
=e),!K)return F=null,void
n();K.defaultSenderId="64148182473",n(K)})}))).then(function()
{n.apply(null,e)})}}z.globalRefresh=function(){console.log("license global
refresh");var n=chrome.app.window.getAll();for(var e in
n)W(e=n[e])},chrome.identity.onSignInChanged.addListener(function()
{console.log("onSignInChanged, refreshing license"),z.refresh(null,!
0)}),chrome.storage.local.get("keyboard",function(n)
{V=n.keyboard}),chrome.storage.local.get("vysorHttp",function(n){if(n){var
e=n.vysorHttp||{};e.password=e.password||
Math.round(Math.random()*(1<<30)).toString(16);var t={"/device/(.*?)/screenshot-?
(.*?).jpg":function(n,e,t){var i=t[1],r=chrome.app.window.get(i);if(!r)return
console.error("device window",i,"not found"),e.code(404),void e.write("",function()
{e.end()});i=r.contentWindow.device.serialno;var
s=r.contentWindow.password;Adb.createSocketFactory(i).newSocket("tcp:53516",functio
n(n){if(!n)return console.error("no socket",i,"for screenshot"),e.code(404),void
e.write("",function(){e.end()});e.headers.Connection="close",e.headers["Content-
Type"]="application/binary",e.headers["Cache-Control"]="no-cache";var t=new
HttpRequestParser(null,n,function(){var
n=t.body.buffer.slice(t.body.byteOffset,t.body.byteOffset+t.body.byteLength);e.writ
e(n,function(){e.end()})});n.write(o("GET /screenshot.jpg?password="+s+"
HTTP/1.1\r\nConnection: close\r\n\r\n"),function(n){})})},"/device/(.*?)/sdcard-
vysor/(.*)":function(n,e,t){var i=t[1],o=chrome.app.window.get(i);if(!o)return
console.error("device window",i,"not found"),e.code(404),void e.write("",function()
{e.end()});i=o.contentWindow.device.serialno;var
r=t[2];e.headers.Connection="close",e.headers["Cache-Control"]="no-
cache",e.headers["Content-
Type"]="application/binary",Adb.pull({file:"/sdcard/vysor/"+r,serialno:i,socket:e},
function(){e.end()})},"/device/(.*?)/audio.adts":function(n,e,t){var
i=t[1],o=chrome.app.window.get(i);if(!z.t())return console.error("ignoring request,
not licensed"),e.code(402),void e.write("This feature is only available in Vysor
Pro",function(){e.end()});if(!o)return console.error("device window",i,"not
found"),e.code(404),void e.write("",function(){e.end()});if(!
o.contentWindow.siphonAudio)return console.error("siphonAudio",i,"not
found"),e.code(404),void e.write("",function(){e.end()});var r=new
O;if(e.headers.Connection="close",e.headers["Content-
Type"]="audio/aac",Socket.pump(r,e,function(){console.log("aac source
closed")}),isElectron()){var s=r;r={dataReceived:function(n)
{s.dataReceived(n)},destroy:s.destroy.bind(r)}}o.contentWindow.siphonAudio(r)},"/de
vice/(.*?)/video.flv":function(n,e,t){var i=t[1],o=chrome.app.window.get(i);if(!
z.t())return console.error("ignoring request, not licensed"),e.code(402),void
e.write("This feature is only available in Vysor Pro",function(){e.end()});if(!
o)return console.error("device window",i,"not found"),e.code(404),void
e.write("",function(){e.end()});if(!o.contentWindow.siphonFlv)return
console.error("siphonFlv",i,"not found"),e.code(404),void e.write("",function()
{e.end()});var r=new O;if(e.headers.Connection="close",e.headers["Content-
Type"]="video/x-flv",Socket.pump(r,e,function(){console.log("flv source
closed")}),isElectron()){var s=r;r={dataReceived:function(n)
{s.dataReceived(n)},destroy:s.destroy.bind(r)}}o.contentWindow.siphonFlv(r)}};!
function n(){Y.listen({port:e.port||0,address:"127.0.0.1"},function(n,e){var
i,o;for(var r in console.log("http
request",n.path),t)if(i=n.path.match(r),o=t[r],i)break;if(!i)return
e.code(404),void e.write("",function(){});o(n,e,i)},function(t){if(t)return
console.error("http server failed to listen",t),void(e.port&&(console.log("trying
port 0"),e.port=0,n()));e.port=Y.socket.localPort,console.log("vysor http port:
"+e.port),chrome.storage.local.set({vysorHttp:e})})}()}else console.error("unable
to start vysor httpServer, no
dict")}),z.refresh(),chrome.app.runtime.onLaunched.addListener(function(n)
{dn(),n&&"vysor_purchase"==n.id&&z.refresh(null,!
0),n&&"vysor_presentation"==n.id&&mn(n.url,function(n)
{sn(n)}),n&&"vysor_device_farm"==n.id&&(console.log("device
farm",n.url),R&&R.show(),dn(),m("Vysor is connecting to shared Android
devices"),D(!0,function(e){e?un(n.url,e,function(n,e){X("Vysor Share",e?"Unable to
connect to shared devices. "+e:"Connected to "+n.name+"'s remote
devices.")}):m("Unable to get auth
token")})),wn()}),un=bn(un),ln=bn(ln),gn=bn(gn),mn=bn(mn),chrome.storage.local.get(
"share-all-devices",function(n){n["share-all-devices"]&&ln(!1,function()
{G()})});var kn,An,Sn,Dn,Un,On,Cn,Tn,En={},Nn={},In={},Bn={},Vn={};function Pn(n)
{var e=Vn[n];clearTimeout(e),Vn[n]=setTimeout(function(){delete Vn[n]},1e4),delete
Bn[n]}function Rn(n){var e=Bn[n];clearTimeout(e),Bn[n]=setTimeout(function(){delete
Bn[n]},1e4),delete Vn[n]}function xn(n){en(n);var e=M[n];e&&e.destroy()}function
Mn(n,e){j[n]?yn(n):gn(n,e),qn()}function jn(n){function e(e){var
o=e+":5555";En[n]=o,Nn[o]=n;var r=In[o];function s(n,e)
{Adb.sendHostCommand("host:disconnect:"+o,function(t,r){t&&t.destroy(),delete
In[o],Adb.sendHostCommand("host:connect:"+o,function(t,r){return t?(t.destroy(),-1!
=(r=i(r)).indexOf("unable to connect")?(m("Unable to connect via wireless. Is your
Android on the same network as your PC?"),void(e&&e(r))):
(e&&e(),chrome.storage.local.set({lastConnectAddress:o}),console.log("adb connect
result",r),void(n&&c()))):(m("Unable to connect via wireless. Is your Android on
the same network as your PC?"),void(e&&e("host connect failed")))})})}function c()
{qn(),setTimeout(function(){m("Vysor is connected wirelessly. You may disconnect
your device."),L.sendEvent("go-wireless"),Rn(o),sn(o,!0,function(n)
{Pn(o),n.contentWindow.tryReconnect=function(){Pn(o),s(!
1)}})},3e3)}r&&(r.id=n),Nn[n]&&(device.id=Nn[n]),r&&"device"==r.status?c():
(Rn(n),t.newSocket("tcpip:5555",function(n){n?a(n,function(n)
{console.log("tcpip:5555 result",n),s(!0,function(n)
{n&&(console.error("host:connect failed, trying again in a few
seconds",n),setTimeout(function(){s(!0,function(n){n&&console.err("host:connect
failed again, giving up.",n)})},3e3))})}):m("Failure while switching to wireless
mode.")}))}var t=Adb.createSocketFactory(n);t.newSocket("shell:ip -f inet addr show
wlan0",function(n){n?a(n,function(n){console.log("ifconfig result",n);var
i=n.match("inet addr:(.*?) ");(i||(i=n.match("wlan0: ip (.*?) ")),i)?
e(i[1]):t.newSocket("shell:ip -f inet addr show wlan0",function(n){n?
a(n,function(n){console.log("ifconfig result",n);var t=n.match("inet (.*?)/");t?
e(t[1]):m("Unable to switch to wireless mode. Is your Android connected to
Wifi?")}):console.log("error running tcpip:5555")})}):console.log("error running
tcpip:5555")})}function qn(){An||(An=e(function()
{An=null,R&&R.contentWindow.refreshList&&R.contentWindow.refreshList(In,M,_,q,j,Nn,
En,K&&K.isListening("share"),kn,x.isRunning(),Dn)}))}function Ln(){if(!kn)
{if(isElectron()){var
n=require("os").platform(),e=chrome.runtime.getAppDirectory(),t=require("path").joi
n(e,"native",n,"adb");i
f("win32"==n)t+=".exe";else try{require("fs").chmodSync(t,"755")}catch(n)
{console.warn("unable to chmod adb",n)}return console.log("attempting to start
built in adb binary",t),void require("child_process").execFile(t,["start-
server"])}Dn||
window.chrome&&window.chrome.runtime&&window.chrome.runtime.connectNative&&((Dn=chr
ome.runtime.connectNative("com.clockworkmod.adb")).onDisconnect.addListener(functio
n(){Dn=null}),Dn.postMessage({command:"start-server"}))}}function Jn()
{Cn=v(Cn,null,300,function(){chrome.storage.local.get("connect-
automatically",function(n){var e;e=!1===n["connect-automatically"]?2:!
0===n["connect-automatically"]?0:n["connect-automatically"]||
1,Adb.devices(function(n){n?($.each(n,function(t,i){var
o=n[t];Nn[t]&&(o.id=Nn[t]);var r=In[t];if(!r||o.status!=r.status){yn(t);var s=-1!
=o.properties.indexOf("emulator")||-1!=o.properties.indexOf("vbox"),c=rn(t);if(!
s&&Sn&&!Bn[c])if(chrome.app.window.get(c)||x.isRunning()||Vn[c])h()&&sn(t,!0);else
if(2!=e&&h()&&"device"==o.status){var a=chrome.runtime.getManifest().name;if(1!
=e)return chrome.notifications.create("never-start-automatically",
{type:"basic",iconUrl:"/icon.png",title:a,message:"Vysor has connected to an
Android device and is starting.",buttons:[{title:"Never Start
Automatically"}]}),void sn(t,!0);chrome.notifications.create("never-start-
automatically-"+Math.random(),
{type:"basic",iconUrl:"/icon.png",title:a,message:"Vysor has detected an Android
device.",buttons:[{title:"View Android with Vysor"},{title:"Never Start
Automatically"}]},function(n){var e=function(t)
{t==n&&(chrome.notifications.onClosed.removeListener(e),chrome.notifications.onButt
onClicked.removeListener(i))},i=function(e,i)
{e==n&&(chrome.notifications.clear(e),0==i?sn(t,!
0):chrome.storage.local.set({"connect-automatically":!
1}))};chrome.notifications.onClosed.addListener(e),chrome.notifications.onButtonCli
cked.addListener(i)})}}function h(){return"unauthorized"!=o.status||(m("Vysor has
detected an Android device. Please Allow USB Debugging on your Android device to
continue."),!1)}}),In=n):In={},qn(),Sn=!0})})})}function $n(){On||
(Adb.sendHostCommand("host:version",function(n,e)
{n&&(n.destroy(),e=i(e),console.log("ADB Server Version:
",e))}),Adb.sendHostCommand("host:track-devices",function(n){On?
n.destroy():n&&(console.log("Connected to ADB Server"),x.isRunning()?
console.log("Using Vysor ADB"):console.log("Using Android SDK ADB"),kn=!
0,n.onClose=function(){On=null,kn=!1,Jn()},On=n,function n(e){e.read(function(t)
{Jn(),n(e)})}(n),Jn())}))}!function n(){$n(),Un||
Ln(),Un=v(Un,null,1e4,Ln),setTimeout(n,1e3)}
(),Jn(),chrome.runtime.onUpdateAvailable.addListener(function()
{on()}),chrome.notifications.onButtonClicked.addListener(function(n,e){"reload"==n?
chrome.runtime.reload():"never-start-
automatically"==n&&(chrome.storage.local.set({"connect-automatically":!
1}),chrome.notifications.clear(n))}),chrome.notifications.onClicked.addListener(fun
ction(n,e){})}("undefined"==typeof window?window={}:window);
<HTML>
<Head><Title> Liste. Problem&#259 </Title></Head>
<Body>
<OL>
Un sistem informatic include:
<LI> Hardware:
<OL TYPE=A>
<LI> placa de baza
<LI> procesor
<LI> memorie
<LI> harddisk
</OL>
<!-- bruh bruh bruh-->
<LI> Software:
<UL TYPE=circle>
<LI> Linux
<LI> Windows
<LI> OS/2
<LI> Unix
</UL>
<LI> Software de aplicatie:
<UL TYPE=disc>
<LI> VisualC++
<LI> Java
<LI> SQL
<LI> CorelDraw
</UL>
</Body>
</HTML><HTML>
<Head><Title> Liste. Problem&#259 </Title></Head>
<Body>
<OL>
Un sistem informatic include:
<LI> Hardware:
<OL TYPE=A>
<LI> placa de baza
<LI> procesor
<LI> memorie
<LI> harddisk
</OL>
<!-- bruh bruh bruh-->
<LI> Software:
<UL TYPE=circle>
<LI> Linux
<LI> Windows
<LI> OS/2
<LI> Unix
</UL>
<LI> Software de aplicatie:
<UL TYPE=disc>
<LI> VisualC++
<LI> Java
<LI> SQL
<LI> CorelDraw
</UL>
</Body>
</HTML><HTML>
<Head><Title> Liste. Problem&#259 </Title></Head>
<Body>
<OL>
Un sistem informatic include:
<LI> Hardware:
<OL TYPE=A>
<LI> placa de baza
<LI> procesor
<LI> memorie
<LI> harddisk
</OL>
<!-- bruh bruh bruh-->
<LI> Software:
<UL TYPE=circle>
<LI> Linux
<LI> Windows
<LI> OS/2
<LI> Unix
</UL>
<LI> Software de aplicatie:
<UL TYPE=disc>
<LI> VisualC++
<LI> Java
<LI> SQL
<LI> CorelDraw
</UL>
</Body>
</HTML><HTML>
<Head><Title> Liste. Problem&#259 </Title></Head>
<Body>
<OL>
Un sistem informatic include:
<LI> Hardware:
<OL TYPE=A>
<LI> placa de baza
<LI> procesor
<LI> memorie
<LI> harddisk
</OL>
<!-- bruh bruh bruh-->
<LI> Software:
<UL TYPE=circle>
<LI> Linux
<LI> Windows
<LI> OS/2
<LI> Unix
</UL>
<LI> Software de aplicatie:
<UL TYPE=disc>
<LI> VisualC++
<LI> Java
<LI> SQL
<LI> CorelDraw
</UL>
</Body>
</HTML>

Das könnte Ihnen auch gefallen