You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

1 lines
16 KiB

"use strict";function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,o){for(var t=0;t<o.length;t++){var i=o[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(o,t,i){return t&&e(o.prototype,t),i&&e(o,i),o}}();!function(){function e(e){for(var o=document.cookie.split("; "),t=0;t<o.length;t++){var i=o[t].split("=");if(i[0]==e)return decodeURIComponent(i[1])}}function o(e){window.csdn&&window.csdn.report&&window.csdn.report.reportClick(e)}function t(e){window.csdn&&window.csdn.report&&window.csdn.report.reportView(e)}function i(){var e=/(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone|csdn)/i.test(navigator.userAgent);return/(MicroMessenger)/i.test(navigator.userAgent)?!/(WindowsWechat|MacWechat)/i.test(navigator.userAgent):e}function n(){var e=window.navigator.userAgent,o="others",t={Sogou:/SE\s2\.X|SogouMobileBrowser/,HuaWei:/HuaweiBrowser/,Quark:/Quark/,Explorer2345:/2345Explorer|2345chrome|Mb2345Browser/,Liebao:/LBBROWSER/,QQBrowser:/QQBrowser/,Baidu:/BIDUBrowser|baidubrowser|BaiduHD/,Toutiao:/NewsArticle|NewsLite/,UC:/UBrowser|UCBrowser|UCWEB/,MiuiBrowser:/MiuiBrowser/,Wechat:/MicroMessenger/,MobileQQ:/Mobile\/\w{5,}\sQQ\/(\d+[\.\d]+)/,Shoujibaidu:/baiduboxapp/,Firefox:/Firefox/,Maxthon:/Maxthon/,Se360:/360SE/,Ee360:/360EE/,Wukong:/GoldBrowser|WukongSearch|wksearch/,TheWorld:/TheWorld/,Weibo:/__weibo__/,NokiaBrowser:/NokiaBrowser/,Opera:/Opera|OPR\/(\d+[\.\d]+)/,Edge:/Edge/,IE:/Trident|MSIE/,Chrome:/Chrome|CriOS/,Safari:/Version[|\/]([\w.]+)(\s\w.+)?\s?Safari|like\sGecko\)\sMobile\/\w{3,}$/,AndroidBrowser:/Android.*Mobile\sSafari|Android\/(\d[\.\d]+)\sRelease\/(\d[\.\d]+)\sBrowser\/AppleWebKit(\d[\.\d]+)/i};for(var i in t)if(t[i].exec(e)){o=i;break}return o}function s(){var e=/micromessenger/.test(navigator.userAgent.toLowerCase()),o=/wxwork/.test(navigator.userAgent.toLowerCase());if("undefined"!=typeof WeixinJSBridge||e)return!o}function r(e){this.app=c(),this.isMobile=i(),this.cb=void 0,this.payInfo=void 0,e&&e.cb&&(this.cb=e.cb),e&&e.biz&&"pay"===e.biz&&e.payInfo&&(this.payInfo=e.payInfo),this.cb&&(delete e.cb,e.hascb="yes"),this.payInfo&&delete e.payInfo,this.inputData=e,this.defaultParams={domain:"csdn.net",isIframe:!0,frameWidth:this.isMobile?343:410,frameHeight:this.isMobile?410:520,append:"#passportbox",iframeName:"passport_iframe",from:encodeURIComponent(window.location.href),pvSource:"",service:"",loginService:this.isMobile?"https://passport.csdn.net/waplogin":"https://passport.csdn.net/account/login"};var o=d&&d.spm?d.spm:"",t=e&&e.spm?e.spm:"",n=t||o;n&&(this.inputData=this.inputData||{},this.inputData.spm=f(n)),this.options=Object.assign({},this.defaultParams,this.inputData),this.extend="",this.version=this.isMobile?"popupv1":"loginv3",this.renderCss(),this.fileExtends(),this.init(this.options)}var a=null,d={};window.csdn=window.csdn||{};var l=function(e,o,t){var i=new Date;if(t)"number"==typeof t?i.setTime(i.getTime()+t):i=new Date(i.getFullYear(),i.getMonth(),i.getDate()+1,0,0,0);else{i.setTime(i.getTime()+2592e6)}document.cookie=e+"="+encodeURIComponent(o)+";expires="+i.toGMTString()+";domain=.csdn.net;path=/"},p=function(e){var o=/([^?#*&=]+)=([^?#*&=]+)/g,t={};return location.href.replace(o,function(){for(var e=arguments.length,o=Array(e),i=0;i<e;i++)o[i]=arguments[i];var n=o[1],s=o[2];t[n]=s}),t[e]},c=function(){return navigator.userAgent.toLowerCase().indexOf("csdn")>-1},h=function(){if(c()){var e=navigator.userAgent.toLowerCase(),o=JSON.stringify({url:"csdnapp://app.csdn.net/login/quick"});/iphone|ipad|ipod|ios/i.test(e)?window.webkit.messageHandlers.csdnjumpnewpage.postMessage(o):window.jsCallBackListener.csdnjumpnewpage(o)}},u=function(){if(c()){/iphone|ipad|ipod|ios/i.test(navigator.userAgent.toLowerCase())?window.webkit.messageHandlers.csdnLogOut.postMessage(null):window.jsCallBackListener.csdnLogOut()}},f=function(e){e=String(e);var o=e.split(".").length;if(2===o||3===o){var t=document.querySelector('meta[name="report"]'),i=t&&t.getAttribute("content")||"{}",n=JSON.parse(i);return n.spm?n.spm+"."+e:e}return e};r.prototype.init=function(e){if(this.app)return window.csdn.loginBox.self=void 0,h(),!1;this.wapDistribute(e)},r.prototype.fileExtends=function(){for(var e in this.inputData)this.defaultParams.hasOwnProperty(e)||(this.extend=this.extend+"&"+e+"="+this.inputData[e])},r.prototype.renderCss=function(){var e=window.document.head,o=e.firstElementChild||e.firstChild,t=document.createElement("style");t.innerText=".passport-login-container{position: fixed;top: 0;left: 0;z-index: 9999;width: 100%;height: 100%;}.passport-login-box{position: absolute;display: block;border-radius: 8px;left: 50%;top: 50%;z-index: 10001;-webkit-transform: translate(-50%, -50%);-ms-transform: translate(-50%, -50%);-o-transform: translate(-50%, -50%);-moz-transform: translate(-50%, -50%);transform: translate(-50%, -50%);background-color: #fff;}.passport-login-mark{position: absolute;top: 0;left: 0;z-index: 9999;background-color: rgba(0, 0, 0, 0.5);width: 100%;height: 100%;}",e.insertBefore(t,o)},r.prototype.renderHtml=function(e){var o=this,i=this.options.loginService;this.$loginDom=$('<div class="passport-login-container"><div id='+this.options.append.replace(/[#\.]/,"")+' class="passport-login-box" style="display: block;'+(this.options.frameHeight?"height:"+this.options.frameHeight+"px":"")+'"></div></div>'),this.$markDom=$('<div class="passport-login-mark"></div>'),window.document.domain=this.options.domain,i=i+(-1===i.indexOf("?")?"?from=":"&from=")+this.options.from,i=this.options.service?i+"&service="+this.options.service:i,i+="&iframe=true",i+="&newframe=true",i=this.options.pvSource?i+"&"+this.options.pvSource:i,i=this.version?i+"&version="+this.version:i,i=this.extend?i+this.extend:i,this.$iframeHtml=$('<iframe width="'+this.options.frameWidth+'" height="'+this.options.frameHeight+'" name="'+this.options.iframeName+'" src="'+i+'" style="border-radius: 8px;" frameborder="0" scrolling="no"></iframe>'),this.$closeBtn=$('<span style="display: inline-block; color: #999; font-size: 22px; cursor: pointer; position:absolute; top:2%; right:3%;-moz-user-select:none; -webkit-user-select:none; user-select:none;">&times</span>'),this.$closeBtn.on("click",function(){o.close()}),this.$markDom.on("click",function(){o.close()}),this.$loginDom.append(this.$markDom),$("body").append(this.$loginDom),$(this.options.append).append(this.$iframeHtml),$(this.options.append).append(this.$closeBtn);var n={};return"auto"!==e.showType?n={spm:"3001.6428"}:"10s"===e.way?n={spm:"3001.7902"}:"3t"===e.way?n={spm:"3001.7961"}:"30m"===e.way?n={spm:"3001.8531"}:"download"===e.way&&(n={spm:"3001.8532"}),t(n),!0},r.prototype.close=function(){o({spm:"3001.6428"}),this.$loginDom.remove(),window.csdn.loginBox.self=void 0},r.prototype.getVersion=function(e){var o=this;$.ajax({type:"get",url:"https://passport.csdn.net/v1/register/pc/iframe/login/version",crossDomain:!0,xhrFields:{withCredentials:!0},contentType:"application/json",success:function(t){t.status?(o.options.frameWidth=t.data.width,o.options.frameHeight=t.data.height,o.version=t.data.controlVersion,o.renderHtml(e)):o.renderHtml(e)},error:function(t){o.renderHtml(e)}})},r.prototype.wapDistribute=function(e){var o=this,t={platform:o.isMobile?"WAP":"PC",source:o.options.pvSource,spm:o.options.spm};$.ajax({type:"get",url:"https://passport.csdn.net/v1/login/distribute/login/route?from="+o.options.from,data:t,crossDomain:!0,xhrFields:{withCredentials:!0},contentType:"application/json",success:function(t){if(t.status){if(!t.data.popup)return window.csdn.loginBox.self=void 0,window.location.href=t.data.routeUrl,!1;o.options.frameWidth=t.data.width,o.options.frameHeight=t.data.height,o.version=t.data.version,o.isMobile&&t.data&&t.data.img&&(o.options.loginService=o.options.loginService+"?popimg="+t.data.img),o.renderHtml(e)}else o.renderHtml(e)},error:function(t){o.renderHtml(e)}})};var m=function(){function o(e){_classCallCheck(this,o),this.callBackFn=e&&e.cb||null,this.errorFn=e&&e.error||null,e&&delete e.cb,e&&delete e.error,this.biz="",this.subBiz="",e&&e.biz&&(this.biz=e.biz,delete e.biz),e&&e.subBiz&&(this.subBiz=e.subBiz,delete e.subBiz),this.app=c(),this.isMobile=i(),this.inputData=e,this.defaultParams={status:"activate",domain:"csdn.net",isIframe:!0,frameWidth:this.isMobile?295:366,frameHeight:this.isMobile?370:408,append:"#passportbox2",iframeName:"passport_iframe2",from:encodeURIComponent(window.location.href),loginService:"https://passport.csdn.net/key"},e&&e.spm&&(this.inputData.spm=f(e.spm)),this.options=Object.assign({},this.defaultParams,this.inputData),this.extend="",this.renderCss(),this.fileExtends(),this.init(this.options)}return _createClass(o,[{key:"getUserStatus",value:function(o){var t=this;$.ajax({url:"https://passport.csdn.net/v1/api/check/userstatus",timeout:5e3,type:"POST",contentType:"application/json",xhrFields:{withCredentials:!0},data:JSON.stringify({username:e("UserName")||"",biz:this.biz,subBiz:this.subBiz}),dataType:"json",success:function(e){if(e.status)if(e.detail){switch(e.detail){case"deleted":t.options.status="deleted",t.options.frameHeight=178;break;case"activate":t.options.status="activate";break;case"speechForbidden":t.options.status="forbidden";break;default:return!0}t.renderHtml()}else t.executeCallBack();else t.close(),window.csdn.loginBox.show()},error:function(e){throw t.executeError(e),void 0,new Error(e.responseText)}})}},{key:"renderCss",value:function(){var e=window.document.head,o=e.firstElementChild||e.firstChild,t=document.createElement("style");t.innerText=".passport-login-container2{position: fixed;top: 0;left: 0;z-index: 9999;width: 100%;height: 100%;}.passport-login-box2{position: absolute;display: block;border-radius: 8px;left: 50%;top: 50%;z-index: 10001;-webkit-transform: translate(-50%, -50%);-ms-transform: translate(-50%, -50%);-o-transform: translate(-50%, -50%);-moz-transform: translate(-50%, -50%);transform: translate(-50%, -50%);background-color: #fff;}.passport-login-mark2{position: absolute;top: 0;left: 0;z-index: 9999;background-color: rgba(0, 0, 0, 0.5);width: 100%;height: 100%;}",e.insertBefore(t,o)}},{key:"renderHtml",value:function(e){var o=this,i=this.options.loginService;if(this.$loginDom=$('<div class="passport-login-container2"><div id='+this.options.append.replace(/[#\.]/,"")+' class="passport-login-box2" style="display: block;'+(this.options.frameHeight?"height:"+this.options.frameHeight+"px":"")+'"></div></div>'),this.$markDom=$('<div class="passport-login-mark2"></div>'),window.document.domain=this.options.domain,i=i+(-1===i.indexOf("?")?"?status=":"&status=")+this.options.status,i=this.extend?i+this.extend:i,this.$iframeHtml=$('<iframe width="'+this.options.frameWidth+'" height="'+this.options.frameHeight+'" name="'+this.options.iframeName+'" src="'+i+'" style="border-radius: 8px;" frameborder="0" scrolling="no"></iframe>'),this.$closeBtn=$('<span style="display: inline-block; color: #999; font-size: 22px; cursor: pointer; position:absolute; top:2%; right:3%;-moz-user-select:none; -webkit-user-select:none; user-select:none;">&times</span>'),this.$closeBtn.on("click",function(){o.close()}),this.$markDom.on("click",function(){o.close()}),this.$loginDom.append(this.$markDom),$("body").append(this.$loginDom),$(this.options.append).append(this.$iframeHtml),$(this.options.append).append(this.$closeBtn),this.options.spm){t({spm:this.options.spm})}}},{key:"close",value:function(){this.$loginDom&&this.$loginDom.remove(),window.csdn.loginBox.self2=void 0}},{key:"fileExtends",value:function(){for(var e in this.inputData)this.defaultParams.hasOwnProperty(e)||(this.extend=this.extend+"&"+e+"="+this.inputData[e])}},{key:"init",value:function(e){this.getUserStatus()}},{key:"executeCallBack",value:function(){this.callBackFn&&this.callBackFn(),this.close()}},{key:"executeError",value:function(e){this.errorFn&&this.errorFn(e),this.close()}}]),o}();window.csdn.loginBox={self:void 0,self2:void 0,show:function(o){return e("UserName")?void void 0:c()?void new r(o):void(this.self||(this.self=new r(o)))},key:function(e){this.self2||(this.self2=new m(e))},close:function(){return this.self.close()},loginout:function(e){if(c())return u(),!1;var o=Object.assign({},e);return new Promise(function(e,t){$.ajax({type:"post",url:"https://passport.csdn.net/account/logout",data:JSON.stringify(o),crossDomain:!0,contentType:"application/json",xhrFields:{withCredentials:!0},success:function(o){e(o)},error:function(e){t(e)}})})},setlogin:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{UserName:void 0,UserToken:void 0},o=e.UserName||p("UserName"),t=e.UserToken||p("UserToken"),i=Object.assign({},{username:o,userToken:t});return new Promise(function(e,o){$.ajax({type:"post",url:"https://passport.csdn.net/v1/login/wap/userToken/refresh",data:JSON.stringify(i),crossDomain:!0,contentType:"application/json",xhrFields:{withCredentials:!0},success:function(o){e(o)},error:function(e){o(e)}})})}},$(document).on("click",".c-login-check",function(o){d=$(this).data("reportClick")||$(this).parent().data("reportClick")||$(this).parent().parent().data("reportClick")||{},e("UserName")||(o.stopPropagation(),window.csdn.loginBox.show())}),$(document).ready(function(){var o=n(),t=e("popTimes"),r=e("popShowed10s"),a=e("popShowed3t"),d="Baidu"===o||"Shoujibaidu"===o,p="Toutiao"===o,h="Wukong"===o,u=s();if(window.location.pathname.indexOf("/article/details")>=0&&i()&&!c()&&!e("UserName")&&!d&&!u&&!p&&!h){var f=setTimeout(function(){r?(clearTimeout(f),f=null):(window.csdn.loginBox.show({showType:"auto",way:"10s",spm:"3001.7902"}),l("popShowed10s","yes","toToday24h"),clearTimeout(f),f=null)},1e4);t?"one"===t?l("popTimes","two","toToday24h"):a||(window.csdn.loginBox.show({showType:"auto",way:"3t",spm:"3001.7961"}),l("popShowed3t","yes","toToday24h")):l("popTimes","one","toToday24h")}}),$(document).on("visibilitychange ready",function(o){var t=n(),r="Baidu"===t||"Shoujibaidu"===t,d="Toutiao"===t,p="Wukong"===t,h=s(),u=e("popShowed30m"),f=window.location.pathname,m=f.indexOf("/article/details")>=0;u||!i()||c()||e("UserName")||r||h||d||p||("visible"===o.target.visibilityState?a=window.setInterval(function(){var o=e("popShowed30m"),t=+e("unloadshowm")||0;o?(window.clearInterval(a),a=null):t>=30&&m?(window.csdn.loginBox.show({showType:"auto",way:"30m",spm:"3001.8531"}),l("popShowed30m","yes","toToday24h")):(t++,l("unloadshowm",t,"toToday24h"))},6e4):"hidden"===o.target.visibilityState&&(window.clearInterval(a),a=null))}),$(document).ready(function(){var o=n(),t=e("downloadPopShowed"),r="Baidu"===o||"Shoujibaidu"===o,a=s(),d=window.location.href,p=d.indexOf("https://download.csdn.net/")>=0;t||!p||!i()||c()||e("UserName")||r||a||(window.csdn.loginBox.show({showType:"auto",way:"download",spm:"3001.8532"}),t||l("downloadPopShowed","yes","toToday24h"))}),$(document).ready(function(){var o=s(),t=e("keyTimes"),n=e("keyShowed"),r=window.location.pathname,a=r.indexOf("/article/details")>=0;if(!n&&a&&i()&&!c()&&e("UserName")&&o){var d=setTimeout(function(){if(n)return clearTimeout(d),void(d=null);window.csdn.loginBox.key({spm:"3001.7962"}),n||l("keyShowed","yes","toToday24h"),clearTimeout(d),d=null},1e4);if(!t)return void l("keyTimes","one","toToday24h");if("one"===t)return void l("keyTimes","two","toToday24h");window.csdn.loginBox.key({spm:"3001.7963"}),n||l("keyShowed","yes","toToday24h")}}),window.addEventListener("message",function(e){switch(void 0,e.data){case"key-close":window.csdn.loginBox.self2&&window.csdn.loginBox.self2.close();break;case"im_client":window.csdn.loginBox.self2&&window.csdn.loginBox.self2.close(),window.open("https://csdn.s2.udesk.cn/im_client/?web_plugin_id=29181");break;case"pop":window.csdn.loginBox.self2&&window.csdn.loginBox.self2.close(),window.csdn.loginBox.show();break;case"page_reload":window.csdn.loginBox.self2&&window.csdn.loginBox.self2.close(),window.location.reload();break;case"pay-cb":window.csdn.loginBox.self&&window.csdn.loginBox.self.cb&&window.csdn.loginBox.self.cb();break;case"pay-data":window.csdn.loginBox.self&&window.csdn.loginBox.self.$iframeHtml[0].contentWindow.postMessage({payInfo:window.csdn.loginBox.self.payInfo},"*");break;default:return!1}},!1)}();