【学习笔记】浏览器Console个性化输出
一、效果图展示
二、代码分享,吧如下代码封装到js文件里即可
/* * 张金奎 * 2019-12-6 00:16:40 * 一小群有思想并且有着献身精神的公民可以改变世界。不要怀疑这种说法,事实上,世界正是这样被改变的。 */ hitokoto(); function hitokoto() { $.ajax({ type: "GET", url: "https://hitokoto.jijidown.com/v1/api/hitokoto?maxlength=80", data: {}, dataType: "json", success: function (data) { //alert(data.hitokoto); console.log(data.hitokoto + "《" + data.source+"》"); } }); } if (console) { var outs = [], fi = function () { return { msg: "", style: "" } }; var oi = fi(); oi.msg = " 才雨又晴晴又雨"; oi.style = "padding:10px 40px 10px;line-height:30px;background:url('https://images.cnblogs.com/cnblogs_com/kudsu/1298007/o_200824155830see_no_evil_monkey_310px_1214323_easyicon.net.png') no-repeat;background-size:15% 100%;font-size:1.8rem;color:rgba(184, 149, 88)"; outs.push(oi); oi = fi(); oi.msg = "https://www.netnr.com"; oi.style = "background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #25e),color-stop(0.75, #4f2), color-stop(0.9, #f2f), color-stop(1, #f22) );color:transparent;-webkit-background-clip: text;font-size:1.5em;" outs.push(oi); oi = fi(); oi.msg = "\r\n微博:\nhttps://weibo.com/kudsu\r\n\r\nGitHub:\nhttps://github.com/kudsu\r\n\r\n博客园:\nhttps://www.cnblogs.com/kudsu/\r\n"; outs.push(oi); if (!("ActiveXObject" in window)) { outs.map(function (x) { console.log("%c" + x.msg, x.style); }); } }
三、结束