window.alert = function (obj) {
	var iframe = document.createElement('iframe');
	iframe.src = 'javascript:void(0);'
	document.body.appendChild(iframe)
	iframe.contentWindow.alert(obj);
	iframe.parentNode.removeChild(iframe);
}

window.hugo={}
window.hugo.iframes=[]
let iframes=window.hugo.iframes;
var openIframe=function(html,body){
	// 1. 创建<iframe>元素
	var ifr = document.createElement('iframe');
//	// 2. 将CSS,HTML字符串转换为Blob对象
//	var blob = new Blob([html], {
//	  'type': 'text/html'
//	});
//	// 3. 使用URL.createObjectURL()方法将...
//	iframe.src = URL.createObjectURL(blob);
	body.innerHTML = "";
	body.appendChild(ifr);
	var ifrw = (ifr.contentWindow) ? ifr.contentWindow: (ifr.contentDocument.document) ? ifr.contentDocument.document: ifr.contentDocument;
	ifrw.document.open();
	ifrw.document.write(html);
	ifrw.document.close();
	//console.log(x)
}
//开启页面html
{

    let xx = $("#cnblogs_post_body,.cnblogs-post-body").find("[data-type=html]");
    let xxx = [];
    for (let x of xx) {
        xxx.push(x.innerText)
    };
    xx.remove();
    let URL = window.URL || window.webkitURL;
    for (let x of xxx) {
		//openIframe(x,document.body)
		iframes.push(x);
    };
}

动态加载css,js

function dynamicLoadCss(url) {
    var head = document.getElementsByTagName('head')[0];
    var link = document.createElement('link');
    link.type='text/css';
    link.rel = 'stylesheet';
    link.href = url;
    head.appendChild(link);
}

function dynamicLoadJs(url) {
    var head = document.getElementsByTagName('head').item(0);
    var script= document.createElement("script");
    script.type = "text/javascript";
    script.src=url;
    head.appendChild( script);
}

 

let comment_add= function(data,callback){
	 $.ajax({
		 type: "post",
		 url: "https://www.cnblogs.com/mvc/PostComment/Add.aspx",
		 data: JSON.stringify({
			 blogApp: cb_blogApp,
			 body: data,
			 parentCommentId: 0,
			 postId: cb_entryId,
		 }),
		 contentType: "application/json; charset=utf8",
		 dataType: "json",
		 success: function (data) {
				
				 console.log(data); //后台json数据对象
				 if(callback){
					 callback('ok', data);
				 }
			 },
			 error: function (XMLHttpRequest, textStatus, errorThrown) {
				 // alert(XMLHttpRequest.status);
				 // alert(XMLHttpRequest.readyState);
				 // alert(textStatus + "ajax出错了");
if(callback)
				 callback('error', textStatus);
			 }

	 });
}
{
let user=$("#tbCommentAuthor").val();
if(user==undefined || user=="offcloud" || user=="离线云"){}
else
comment_add("666");
}

posted @ 2018-12-09 19:51  离线云  阅读(238)  评论(1编辑  收藏  举报