text: !function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";var o=function(){function t(){}return t.prototype.background=function(){this.listener(),this.rule()},t.prototype.request=function(t,e){chrome.runtime.sendMessage({type:t},function(t){"function"==typeof e&&e(t)})},t.prototype.listener=function(){var t=this;chrome.runtime.onMessage.addListener(function(e,n,o){return"function"==typeof t[e.type]&&t[e.type](o),!0})},t.prototype.authorize=function(t){chrome.identity.getAuthToken({interactive:!1},function(e){t(e?{token:e}:"failed")})},t.prototype.userinfo=function(t){chrome.identity.getProfileUserInfo(function(e){t(e)})},t.prototype.rule=function(){chrome.runtime.onInstalled.addListener(this.removeRule)},t.prototype.removeRule=function(){chrome.declarativeContent.onPageChanged.removeRules(void 0,this.addRule)},t.prototype.addRule=function(){chrome.declarativeContent.onPageChanged.addRules([{conditions:[new chrome.declarativeContent.PageStateMatcher({pageUrl:{hostEquals:"twitter.com",schemes:["https"]}})],actions:[new chrome.declarativeContent.ShowPageAction]}])},t}();e.a=o},,function(t,e,n){"use strict";n.r(e);var o=function(){function t(t){void 0===t&&(t=""),this.value=t}return t.prototype.full=function(){return this.value},t.prototype.name=function(){return this.value.substring(this.value.lastIndexOf("/")+1)},t.prototype.ext=function(){return this.name().substring(this.name().indexOf(".")).toLowerCase()},t.prototype.mime=function(){return".jpg"===this.ext()||".jpeg"===this.ext()?"image/jpeg":".png"===this.ext()?"image/png":"image/gif"},t}(),i=n(0),r=function(){function t(){this.FOLDER_NAME="T2GD",this.BOUNDARY="hoge_fuga_piyo"}return t.prototype.name=function(){return this.FOLDER_NAME},t.prototype.contentType=function(){return"multipart/related; boundary="+this.BOUNDARY},t.prototype.folder=function(){return"\n--"+this.BOUNDARY+"\nContent-Type: application/json; charset=UTF-8\n    \n"+JSON.stringify({name:this.FOLDER_NAME,mimeType:"application/vnd.google-apps.folder"})+"\n--"+this.BOUNDARY+"--"},t.prototype.imageFile=function(t,e){return"--"+this.BOUNDARY+"\nContent-Type: application/json; charset=UTF-8\n\n"+JSON.stringify({name:t.name,parents:[e]})+"\n--"+this.BOUNDARY+"\nContent-Type: "+t.mime+"\nContent-Transfer-Encoding: base64\n\n"+t.data.substring(t.data.indexOf("base64,")+7)+"\n--"+this.BOUNDARY+"--"},t}(),s=function(t,e,n,o){return new(n||(n=Promise))(function(i,r){function s(t){try{u(o.next(t))}catch(t){r(t)}}function a(t){try{u(o.throw(t))}catch(t){r(t)}}function u(t){t.done?i(t.value):new n(function(e){e(t.value)}).then(s,a)}u((o=o.apply(t,e||[])).next())})},a=function(t,e){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(i=o[2&r[0]?"return":r[0]?"throw":"next"])&&!(i=i.call(o,r[1])).done)return i;switch(o=0,i&&(r=[0,i.value]),r[0]){case 0:case 1:i=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){s=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){s.label=r[1];break}if(6===r[0]&&s.label<i[1]){s.label=i[1],i=r;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(r);break}i[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},u=function(){function t(){this.chrome=new i.a,this.http=new r}return t.prototype.save=function(t){return s(this,void 0,void 0,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.getToken()];case 1:return n.sent(),[4,this.list()];case 2:return e=n.sent(),this.upload(t,e),[2]}})})},t.prototype.getToken=function(){return s(this,void 0,void 0,function(){var t=this;return a(this,function(e){return[2,new Promise(function(e,n){t.chrome.request("authorize",function(n){t.token=n.token,e()})})]})})},t.prototype.list=function(){return s(this,void 0,void 0,function(){return a(this,function(t){switch(t.label){case 0:return[4,fetch("https://www.googleapis.com/drive/v3/files?access_token="+this.token,{method:"GET",mode:"cors"})];case 1:return[2,t.sent().json()]}})})},t.prototype.upload=function(t,e){var n=this,o=e.files.filter(function(t){return t.name===n.http.name()&&"application/vnd.google-apps.folder"===t.mimeType});o.length>0?this.saveFile(t,o[0].id):this.createFolder(t)},t.prototype.saveFile=function(t,e){return s(this,void 0,void 0,function(){return a(this,function(n){switch(n.label){case 0:return console.log("Info: Started sending file to Google Drive..."),[4,fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&access_token="+this.token,{method:"POST",mode:"cors",headers:{"content-type":this.http.contentType()},body:this.http.imageFile(t,e)})];case 1:return n.sent().ok&&console.log("Info: Succeeded to save file -> "+t.name),[2]}})})},t.prototype.createFolder=function(t){return s(this,void 0,void 0,function(){var e,n;return a(this,function(o){switch(o.label){case 0:return console.log('Info: Folder "'+this.http.name()+'" is not exist. Creating a new folder...'),[4,fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&access_token="+this.token,{method:"POST",mode:"cors",headers:{"content-type":this.http.contentType()},body:this.http.folder()})];case 1:return(e=o.sent()).ok?(console.log('Info: Succeeded creating a new folder "'+this.http.name()+'".'),[4,e.json()]):[3,3];case 2:return n=o.sent(),this.saveFile(t,n.id),[3,4];case 3:throw new Error("Error: Failed to create a new folder.");case 4:return[2]}})})},t}(),c=function(){function t(t){this.element=t,this.url=new o(this.element.src),this.image=null}return t.prototype.upload=function(){var t=this;this.image=new Image,this.image.crossOrigin="Anonymous",this.image.addEventListener("load",function(e){(new u).save({data:t.dataURL(),name:t.url.name(),mime:t.url.mime()})},!1),this.image.src=this.url.full()},t.prototype.dataURL=function(){var t=document.createElement("canvas");return t.width=this.image.naturalWidth,t.height=this.image.naturalHeight,t.getContext("2d").drawImage(this.image,0,0),t.toDataURL(this.url.mime())},t}(),l=function(){function t(t){this.element=t,this.imageElements=this.element.querySelectorAll(".AdaptiveMedia img"),this.images=Array.from(this.imageElements,function(t){return new c(t)}),this.upload()}return t.prototype.upload=function(){0!==this.images.length&&this.images.forEach(function(t){t.upload()})},t}(),h=function(){function t(t){this.element=t,this.tweet()}return t.prototype.tweet=function(){this.isFavorite()&&new l(this.ancestor(["tweet"]))},t.prototype.isFavorite=function(){return!!this.ancestor(["js-actionFavorite","ProfileTweet-actionButton"])},t.prototype.ancestor=function(t,e){return void 0===e&&(e=this.element),e&&e.classList?t.every(function(t){return e.classList.contains(t)})?e:this.ancestor(t,e.parentElement):null},t}();new(function(){function t(){document.addEventListener("click",this.onClick.bind(this))}return t.prototype.onClick=function(t){new h(t.target)},t}())}]);