UNPKG

hexo-cnortles-source

Version:

一个HEXO博客的静态资源,可随便使用

816 lines (742 loc) 30.8 kB
/**函数定义区 * 函数定义区 * www.cnortles.top */ //IE内核监测 var isIE = IEVersion(); if (isIE == "6" || isIE == "7" || isIE == "8" || isIE == "9" || isIE == "10" || isIE == "11") { //判断当前是否是IE浏览器 window.location = "/crl/html/kernel.html"; //如果是IE内核跳转至kernel.html } /**统计 */ LA.init({ id: "JkcBsOFTTB5LJIqW", ck: "JkcBsOFTTB5LJIqW", autoTrack: true, hashMode: true }); window.onscroll = percent;// 执行函数 // 页面百分比 function percent() { let a = document.documentElement.scrollTop || window.pageYOffset, // 卷去高度 b = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight, // 整个网页高度 result = Math.round(a / b * 100), // 计算百分比 up = document.querySelector("#go-up"), // 获取按钮 down = document.querySelector("#go-down"); // 获取按钮 if (result <= 95) { up.childNodes[0].style.display = 'none' up.childNodes[1].style.display = down.style.display = 'block' up.childNodes[1].innerHTML = result; } else { up.childNodes[1].style.display = down.style.display = 'none' up.childNodes[0].style.display = 'block' } } // 如果当前页有评论就执行函数 // 表情放大 function owoBig() { let flag = 1, // 设置节流阀 owo_time = '', // 设置计时器 m = 3 // 设置放大倍数 // 创建盒子 let div = document.createElement('div'); // 设置ID div.id = 'owo-big'; // 插入盒子 let body = document.querySelector('body') body.appendChild(div) document.getElementById('post-comment').addEventListener('DOMNodeInserted', (dom) => { if (dom.target.classList && (dom.target.classList.value == 'OwO-body' || 'tk-comment')) { let owo_body = dom.target; // 禁用右键(手机端长按会出现右键菜单,为了体验给禁用掉) owo_body.addEventListener('contextmenu', e => e.preventDefault()) // 鼠标移入 owo_body.addEventListener('mouseover', (e) => { if (e.target.tagName == 'IMG' && flag) { flag = 0; // 移入300毫秒后显示盒子 owo_time = setTimeout(() => { let height = e.path[0].clientHeight * m // 盒子高 let width = e.path[0].clientWidth * m // 盒子宽 let left = (e.x - e.offsetX) - (width - e.path[0].clientWidth) / 2 // 盒子与屏幕左边距离 if ((left + width) > body.clientWidth) { left -= ((left + width) - body.clientWidth + 10) } // 右边缘检测,防止超出屏幕 if (left < 0) left = 10 // 左边缘检测,防止超出屏幕 let top = e.y - e.offsetY // 盒子与屏幕顶部距离 // 设置盒子样式 div.style.height = height + 'px' div.style.width = width + 'px' div.style.left = left + 'px' div.style.top = top + 'px' div.style.display = 'flex' // 在盒子中插入图片 div.innerHTML = `<img src="${e.target.src}">` }, 300); } }) // 鼠标移出 owo_body.addEventListener('mouseout', (e) => { // 隐藏盒子 div.style.display = 'none'; flag = 1 clearTimeout(owo_time) }) } }); } /**友联跳转 */ function random_flink() { fetch("/link") .then(e => e.text()) .then(e => { var t = document.createElement("div"); t.innerHTML = e; var n = t.getElementsByClassName("flink-item-name"); var l = t.querySelectorAll(".flink-list-item a"); n = Array.from(n); l = Array.from(l); var a=6; //可设置为任意开始的位置 var b=l.length; //可设置位任意结束的位置 var num=Math.floor(Math.random()*eval(b)+eval(a))-1; var n_name = n[num].innerText; btf.snackbarShow("温馨提示,您即将前往"+'『'+n_name+'』',!1, 3e3); function jump(){window.location.href=l[num];} setTimeout(jump,2000); }) } /**自定义 */ //标签条 function tagsBarActive(){ var urlinfo = window.location.pathname; urlinfo = decodeURIComponent(urlinfo) //console.log(urlinfo); //判断是否是首页 if (urlinfo == '/'){ if (document.querySelector('#tags-bar')){ document.getElementById('首页').classList.add("select") } }else { // 验证是否是分类链接 var pattern = /\/tags\/.*?\//; var patbool = pattern.test(urlinfo); //console.log(patbool); // 获取当前的标签 if (patbool) { var valuegroup = urlinfo.split("/"); //console.log(valuegroup[2]); // 获取当前分类 var nowTag = valuegroup[2]; if (document.querySelector('#category-bar')){ document.getElementById(nowTag).classList.add("select"); } } } } tagsBarActive() /**背景 * 来源: https://blog.leonus.cn/2022/bg2.html */ // 存数据 // name:命名 data:数据 function saveData(name, data) { localStorage.setItem(name, JSON.stringify({ 'time': Date.now(), 'data': data })) } // 取数据 // name:命名 time:过期时长,单位分钟,如传入30,即加载数据时如果超出30分钟返回0,否则返回数据 function loadData(name, time) { var data = JSON.parse(localStorage.getItem(name)); // 过期或有错误返回 0 if (data != null && 0 < Date.now() - data.time < time * 60 * 1000) return data.data; // 没过期返回数据 else return 0; } // 上面两个函数如果你有其他需要存取数据的功能,也可以直接使用 // 读取背景 try { var data = loadData('blogbg', 1440) if (data) changeBg(data, 1) else localStorage.removeItem('blogbg'); } catch (error) { localStorage.removeItem('blogbg'); } // 切换背景函数 // 此处的flag是为了每次读取时都重新存储一次,导致过期时间不稳定 // 如果flag为0则存储,即设置背景. 为1则不存储,即每次加载自动读取背景. function changeBg(s, flag) { var bg = document.getElementById('web_bg') if (s.charAt(0) == '#') { bg.style.backgroundColor = s bg.style.backgroundImage = 'none' } else bg.style.backgroundImage = s if (!flag) { saveData('blogbg', s) } } // 以下为2.0新增内容 // 创建窗口 var winbox = '' function createWinbox() { winbox = WinBox({ id: 'changeBgBox', index: 999, title: "切换背景", x: "center", y: "center", minwidth: '300px', height: "60%", background: 'var(--leonus-blue)' }); winResize(); window.addEventListener('resize', winResize) // 每一类我放了一个演示,直接往下复制粘贴 a标签 就可以,需要注意的是 函数里面的链接 冒号前面需要添加反斜杠\进行转义 winbox.body.innerHTML = ` <div id="article-container" style="padding:10px;"> <p><button onclick="localStorage.removeItem('blogbg');location.reload();" style="background:#5fcdff;display:block;width:100%;padding: 15px 0;border-radius:6px;color:white;"><i class="fa-solid fa-arrows-rotate"></i> 点我恢复默认背景</button></p> <h2 id="图片(手机)"><a href="#图片(手机)" class="headerlink" title="图片(手机)"></a>图片(手机)</h2> <div class="bgbox"> <a href="javascript:;" rel="noopener external nofollow" style="background-image:url(https://img.vm.laomishuo.com/image/2021/12/2021122715170589.jpeg)" class="pimgbox" onclick="changeBg('url(https\://img.vm.laomishuo.com/image/2021/12/2021122715170589.jpeg)')"></a> </div> <h2 id="图片(电脑)"><a href="#图片(电脑)" class="headerlink" title="图片(电脑)"></a>图片(电脑)</h2> <div class="bgbox"> <a href="javascript:;" rel="noopener external nofollow" style="background-image:url(https://cn.bing.com/th?id=OHR.GBRTurtle_ZH-CN6069093254_1920x1080.jpg)" class="imgbox" onclick="changeBg('url(https\://cn.bing.com/th?id=OHR.GBRTurtle_ZH-CN6069093254_1920x1080.jpg)')"></a> </div> <h2 id="渐变色"><a href="#渐变色" class="headerlink" title="渐变色"></a>渐变色</h2> <div class="bgbox"> <a href="javascript:;" rel="noopener external nofollow" class="box" style="background: linear-gradient(to right, #eecda3, #ef629f)" onclick="changeBg('linear-gradient(to right, #eecda3, #ef629f)')"></a> </div> <h2 id="纯色"><a href="#纯色" class="headerlink" title="纯色"></a>纯色</h2> <div class="bgbox"> <a href="javascript:;" rel="noopener external nofollow" class="box" style="background: #7D9D9C" onclick="changeBg('#7D9D9C')"></a> </div> `; } // 适应窗口大小 function winResize() { var offsetWid = document.documentElement.clientWidth; if (offsetWid <= 768) { winbox.resize(offsetWid * 0.95 + "px", "70%").move("center", "center"); } else { winbox.resize(offsetWid * 0.6 + "px", "70%").move("center", "center"); } } // 切换状态,窗口已创建则控制窗口显示和隐藏,没窗口则创建窗口 function toggleWinbox() { if (document.querySelector('#changeBgBox')) winbox.toggleClass('hide'); else createWinbox(); } /** 最新文章*/ function newPost() { var ls = document.querySelectorAll('.recent-post-info') // 先让时间和索引值都等于第一个的 var time = new Date(ls[0].querySelector('.post-meta-date-created').getAttribute('datetime')).getTime(); var index = 0 // 遍历数组,如果有时间比time大的则替换 ls.forEach((i, num) => { var t = new Date(i.querySelector('.post-meta-date-created').getAttribute('datetime')).getTime() if (t > time) { time = t; index = num } }) // 单数在右,双数在左 var className = index % 2 == 0 ? 'newPost-right' : 'newPost-left' ls[index].innerHTML += '<span class="' + className + '">最 新</span>'; // 如果你不想让其一左一右,可以注释上面的启用下面的 // ls[index].innerHTML += '<span class="newPost-left">最 新</span>'; } /**刷新缓存*/ function refreshCache() { if (confirm('是否确定刷新博文缓存')) location.reload(true) } /**链接粘贴 */ function share() { var e = window.location.origin + window.location.pathname; new ClipboardJS(".share", { text: function () { return document.title + "\n" + e } }); btf.snackbarShow("你的剪切板已被吾辈占领,快去与同伴分享吧~") } /**热更新cw */ async function updateConfig() { await fetch('/cw-cgi/api?type=config').then(res => res.text()).then(res => { if (res === 'ok') { console.log(`[CW]已更新配置`); } else { console.log(`[CW]唔~配置更新失败...`); } }) } /**设置cookie */ function setCookie(name, value, hours, path) { var name = escape(name); var value = escape(value); var expires = new Date(); expires.setTime(expires.getTime() + hours * 3600000); path = path == "" ? "" : ";path=" + path; _expires = (typeof hours) == "string" ? "" : ";expires=" + expires.toUTCString(); document.cookie = name + "=" + value + _expires + path; } //读取cookie function getCookie(name) { var arrStr = document.cookie.split('; '); //alert(arrStr) for (var i = 0; i < arrStr.length; i++) { var arr = arrStr[i].split('=') if (arr[0] == name) { return decodeURIComponent(arr[1]) } } return '' } /**网站提示区 */ function welcome_mes() { if (navigator.userAgent.match(/edg/i)) { var we_mes = 'Edge'; } /**社交软件检测 */ else if (navigator.userAgent.match(/weixin/i)) { var we_mes = '微信'; } else if (navigator.userAgent.match(/ks/i)) { var we_mes = '快手'; } else if (navigator.userAgent.match(/weibo/i)) { var we_mes = '微博'; } else if (navigator.userAgent.match(/dy/i)) { var we_mes = '抖音'; } /**手机厂商浏览器检测区域 */ else if (navigator.userAgent.match(/heytapbrowser/i)) { var we_mes = 'OPPO浏览器'; } else if (navigator.userAgent.match(/vivobrowser/i)) { var we_mes = 'VIVO浏览器'; } else if (navigator.userAgent.match(/HBPC/i) || navigator.userAgent.match(/huaweibrowser/i)) { var we_mes = '华为浏览器'; } else if (navigator.userAgent.match(/iphone/i) && navigator.userAgent.match(/mac/i)) { var we_mes = '苹果设备'; } /**第三方浏览器检测区域 */ else if (navigator.userAgent.match(/quark/i)) { var we_mes = '夸克浏览器'; } else if (navigator.userAgent.match(/firefox/i)) { var we_mes = '火狐浏览器'; } else if (navigator.userAgent.match(/ucbrowser/i)) { var we_mes = 'UC浏览器'; } else if (navigator.userAgent.match(/baidubox/i)) { var we_mes = '百度浏览器'; } else if (navigator.userAgent.match(/opr/i)) { var we_mes = 'Opera浏览器'; } /**else if(navigator.userAgent.match(/360/i)){ var we_mes = '360浏览器';}因多次查证,360浏览器并不包含特有信息,无法查证*/ else if (navigator.userAgent.match(/qq/i)) { var we_mes = 'QQ浏览器'; } else if (navigator.userAgent.match(/chrome/i)) { var we_mes = 'Chrome浏览器'; } /**IP部分 */ if (ip_mes["nation"] == '中国') { var ip_mess = ip_mes["city"]; } else if (ip_mes["city"].match(/台湾/i)) { var ip_mess = "中国台湾"; } else { var ip_mess = ip_mes["nation"] + ip_mes["province"] + ip_mes["city"]; } /**来源检测 */ var we_link = document.referrer; if (we_link.match(/baidu/i)) { var welcome_link = '百度' } else if (we_link.match(/sougou/i)) { var welcome_link = '搜狗' } else if (we_link.match(/weixin/i)) { var welcome_link = '微信' } else if (we_link.match(/qq/i)) { var welcome_link = 'qq' } else if (we_link.match(/zhihu/i)) { var welcome_link = '知乎' } else if (we_link.match(/google/i)) { var welcome_link = '谷歌' } else if (we_link.match(/bing/i)) { var welcome_link = '必应' } else if (we_link.match(/so/i)) { var welcome_link = '360' } else if (we_link.match(/weibo/i)) { var welcome_link = '微博' } else if (we_link.match(/t.co/i)) { var welcome_link = '推特' } else if (we_link.match(/sougou/i)) { var welcome_link = '搜狗' } else if (we_link.match(/toutiao/i)) { var welcome_link = '今日头条' } else { var welcome_link = '远方' } if (getCookie("welcome") == '') { btf.snackbarShow("你好啊,来自" + ip_mess + "的朋友,您使用" + we_mes + "从" + welcome_link + "赶来", !1, 3e3); console.info(ip_mess+we_mes+we_link) setCookie("welcome", '1.8.1', "/"); } } /**搜索引擎推送*/ (function () { var el = document.createElement("script"); el.src = "https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?8ae936feb612a2d4a890825a60def1c7d3172cc27fc13e57bb7e029ed48cc55abc434964556b7d7129e9b750ed197d397efd7b0c6c715c1701396e1af40cec962b8d7c8c6655c9b00211740aa8a98e2e"; el.id = "ttzz"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(el, s); })(window) // 页面百分比 function percent() { let a = document.documentElement.scrollTop, // 卷去高度 b = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight) - document.documentElement.clientHeight, // 整个网页高度 减去 可视高度 result = Math.round(a / b * 100), // 计算百分比 btn = document.querySelector("#go-up"); // 获取按钮 if (result < 95) { // 如果阅读进度小于95% 就显示百分比 btn.childNodes[0].style.display = 'none' btn.childNodes[1].style.display = 'block' btn.childNodes[1].innerHTML = result + '<span>%</span>'; } else { // 如果大于95%就显示回到顶部图标 btn.childNodes[1].style.display = 'none' btn.childNodes[0].style.display = 'block' } } /*grayscale.js-变灰*/ function PublicSacrificeDay() { var PSFarr = new Array("0327", "0403", "0404", "0405", "0406", "0414", "0512", "0707", "0807", "0814", "0909", "0918", "0930", "1025", "1213"); //2022年3月27东航MU5735头七祭 //2020年4月4日 新冠肺炎哀悼日,清明节 //2010年4月14日,青海玉树地震 //2008年5月12日,四川汶川地震 //1937年7月7日,七七事变 又称卢沟桥事变 //2010年8月7日,甘肃舟曲特大泥石流 //8月14日,世界慰安妇纪念日 //1976年9月9日,毛主席逝世 //1931年9月18日,九一八事变 //烈士纪念日为每年9月30日 //1950年10月25日,抗美援朝纪念日 //1937年12月13日,南京大屠杀 var currentdate = new Date(); var str = ""; var mm = currentdate.getMonth() + 1; if (currentdate.getMonth() > 9) { str += mm; } else { str += "0" + mm; } if (currentdate.getDate() > 9) { str += currentdate.getDate(); } else { str += "0" + currentdate.getDate(); } if (PSFarr.indexOf(str) > -1) { return 1; } else { return 0; } } /**运行时间 */ function timer(e, t) { e = Math.round(e / 1e3); var n = Math.round((new Date).getTime() / 1e3); var o = 0; if (t == 0) o = n - e; else o = e - n; var i = new Array(0,0,0,0,0); var a = function(e) { return e > 9 ? e : "0" + e }; if (o >= 365 * 24 * 3600) { i[0] = parseInt(o / (365 * 24 * 3600)); o %= 365 * 24 * 3600 } if (o >= 24 * 3600) { i[1] = parseInt(o / (24 * 3600)); o %= 24 * 3600 } if (o >= 3600) { i[2] = a(parseInt(o / 3600)); o %= 3600 } if (o >= 60) { i[3] = a(parseInt(o / 60)); o %= 60 } if (o >= 0) i[4] = a(o); return i } function runtime() { var e = timer(new Date("2022/7/15 00:00:00").getTime(), 0); var t = "小破站已坚持:"; if (e[0] != 0) t += e[0] + " 年 "; t += e[1] + " 天 " + e[2] + " 时 " + e[3] + " 分 " + e[4] + "秒"; document.getElementById("runtime").innerHTML = t; setTimeout(runtime, 1e3) } /**IE检测 */ function IEVersion() { var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器 var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器 var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1; if (isIE) { var reIE = new RegExp("MSIE (\\d+\\.\\d+);"); reIE.test(userAgent); var IEVersion; IEVersion = parseFloat(RegExp["$1"]); if (IEVersion == 7) { return 7; } else if (IEVersion == 8) { return 8; } else if (IEVersion == 9) { return 9; } else if (IEVersion == 10) { return 10; } else { return 6; //IE版本<=7 } } else if (isEdge) { return 'edge'; //edge } else if (isIE11) { return 11; //IE11 } else { return -1; //不是ie浏览器 } } function getLinks() { fetch("/link").then(e => e.text()).then(e => { var t = document.createElement("div"); t.innerHTML = e; var o = document.querySelectorAll("#friend-links-in-footer .footer-item"); var n = t.getElementsByClassName("flink-item-name"); var l = t.querySelectorAll(".flink-list-item a"); n = Array.from(n); l = Array.from(l); for (var t = 0; t < 5; t++) { var e = parseInt(Math.random() * n.length); o[t].innerText = n[e].innerText; o[t].href = l[e].href; n.splice(e, 1); l.splice(e, 1) } }) } /**漫天繁星 */ function dark() { window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; var n, e, i, h, t = .05, s = document.getElementById("universe"), o = !0, a = "180,184,240", r = "226,225,142", d = "226,225,224", c = []; function f() { n = window.innerWidth, e = window.innerHeight, i = .216 * n, s.setAttribute("width", n), s.setAttribute("height", e) } function u() { h.clearRect(0, 0, n, e); for (var t = c.length, i = 0; i < t; i++) { var s = c[i]; s.move(), s.fadeIn(), s.fadeOut(), s.draw() } } function y() { this.reset = function () { this.giant = m(3), this.comet = !this.giant && !o && m(10), this.x = l(0, n - 10), this.y = l(0, e), this.r = l(1.1, 2.6), this.dx = l(t, 6 * t) + (this.comet + 1 - 1) * t * l(50, 120) + 2 * t, this.dy = -l(t, 6 * t) - (this.comet + 1 - 1) * t * l(50, 120), this.fadingOut = null, this.fadingIn = !0, this.opacity = 0, this.opacityTresh = l(.2, 1 - .4 * (this.comet + 1 - 1)), this.do = l(5e-4, .002) + .001 * (this.comet + 1 - 1) }, this.fadeIn = function () { this.fadingIn && (this.fadingIn = !(this.opacity > this.opacityTresh), this.opacity += this.do) }, this.fadeOut = function () { this.fadingOut && (this.fadingOut = !(this.opacity < 0), this.opacity -= this.do / 2, (this.x > n || this.y < 0) && (this.fadingOut = !1, this.reset())) }, this.draw = function () { if (h.beginPath(), this.giant) h.fillStyle = "rgba(" + a + "," + this.opacity + ")", h.arc(this.x, this.y, 2, 0, 2 * Math.PI, !1); else if (this.comet) { h.fillStyle = "rgba(" + d + "," + this.opacity + ")", h.arc(this.x, this.y, 1.5, 0, 2 * Math.PI, !1); for (var t = 0; t < 30; t++) h.fillStyle = "rgba(" + d + "," + (this.opacity - this.opacity / 20 * t) + ")", h.rect(this.x - this.dx / 4 * t, this.y - this.dy / 4 * t - 2, 2, 2), h.fill() } else h.fillStyle = "rgba(" + r + "," + this.opacity + ")", h.rect(this.x, this.y, this.r, this.r); h.closePath(), h.fill() }, this.move = function () { this.x += this.dx, this.y += this.dy, !1 === this.fadingOut && this.reset(), (this.x > n - n / 4 || this.y < 0) && (this.fadingOut = !0) }, setTimeout(function () { o = !1 }, 50) } function m(t) { return Math.floor(1e3 * Math.random()) + 1 < 10 * t } function l(t, i) { return Math.random() * (i - t) + t } f(), window.addEventListener("resize", f, !1), function () { h = s.getContext("2d"); for (var t = 0; t < i; t++) c[t] = new y, c[t].reset(); u() }(), function t() { document.getElementsByTagName('html')[0].getAttribute('data-theme') == 'dark' && u(), window.requestAnimationFrame(t) }() }; /**函数运行区 * 顺序按照重要程度以及出错概率排序,为避免JS失效 * 作者:落星 ©cnortles.top */ if (window.console) { Function.prototype.makeMulti = function () { var l = new String(this); l = l.substring(l.indexOf("/*") + 3, l.lastIndexOf("*/")); return l; }; var string = function () { /* __ .__ ____ ____ ____________/ |_| | ____ ______ _/ ___\ / \ / _ \_ __ \ __\ | _/ __ \ / ___/ \ \___| | ( <_> ) | \/| | | |_\ ___/ \___ \ \___ >___| /\____/|__| |__| |____/\___ >____ > \/ \/ \/ \/ Powered by crl Ralease 1.8.1. Butterfly 4.4.0. */ }; console.log(string.makeMulti()); } /*grayscale.js-变灰*/ if (PublicSacrificeDay()) { document.getElementsByTagName("html")[0].setAttribute("style", "filter:gray !important;filter:grayscale(100%);-webkit-filter:grayscale(100%);-moz-filter:grayscale(100%);-ms-filter:grayscale(100%);-o-filter:grayscale(100%);"); } /**漫天繁星 */ dark(); /**获取友联链接 */ getLinks(); //开发者模式监测 window.onkeydown = function (e) { 123 === e.keyCode && btf.snackbarShow("开发者模式已打开,请遵循GPL协议", !1, 3e3); console.warn("开发者模式已打开,请遵循GPL协议"); }; //动态标题 var OriginTitile = document.title; var titvarime; document.addEventListener('visibilitychange', function () { if (document.hidden) { //离开当前页面时标签显示内容 document.title = 'w(゚Д゚)w 服务器被黑洞吞了!连接中断......'; clearTimeout(titvarime); } else { //返回当前页面时标签显示内容 document.title = '♪(^∇^*)服务器又从白洞出来了!连接恢复' + OriginTitile; //两秒后变回正常标题 titvarime = setTimeout(function () { document.title = OriginTitile; }, 2000); } }); /**页脚运行时间 */ runtime(); if (document.getElementById('post-comment')) owoBig(); /**最新文章 */ if (location.pathname == '/') newPost(); /**自定义封面 */ /**leave.min.js */ // /**封面背景 */ // if (document.getElementById('post-cover')) { // const img = document.getElementById('post-cover').getAttribute('data-lazy-src') // RGBaster.colors(img, { // pavarteSize: 30, // exclude: ["rgb(255,255,255)", "rgb(0,0,0)", "rgb(254,254,254)"], // success: function(t) { // if (t.dominant != 'rgb()'){ // const c = t.dominant.match(/\d+/g); // const Color = `rgba(${c[0]},${c[1]},${c[2]},0.8)`; // var fontColor; // //const grayLevel = c[0] * 0.299 + c[1] * 0.587 + c[2] * 0.114; // const grayLevel = c[0] * 0.213 + c[1] * 0.715 + c[2] * 0.072; // //if (grayLevel >= 190) { // if (grayLevel >= 255/2) { // // 若为浅色,把文字设置为黑色 // fontColor = '#000'; // metaColor = '#1C1C1C'; // } else { // fontColor = '#fff'; // metaColor = '#eee'; // } // document.styleSheets[0].addRule(":root", "--mj-main:" + Color + "!important") // document.styleSheets[0].addRule(":root", "--mj-titlecolor:" + fontColor + "!important") // document.styleSheets[0].addRule(":root", "--mj-metacolor:" + metaColor + "!important") // } else { // document.styleSheets[0].addRule(":root", "--mj-main: rgba(255,250,240,0.5) !important") // document.styleSheets[0].addRule(":root", "--mj-titlecolor: #000 !important") // document.styleSheets[0].addRule(":root", "--mj-metacolor: #1C1C1C !important") // } // }, // error: function() { // document.styleSheets[0].addRule(":root", "--mj-main: rgba(255,250,240,0.5) !important") // document.styleSheets[0].addRule(":root", "--mj-titlecolor: #000 !important") // document.styleSheets[0].addRule(":root", "--mj-metacolor: #1C1C1C !important") // } // }) // } else { // document.styleSheets[0].addRule(":root", "--mj-main: transparent !important") // document.styleSheets[0].addRule(":root", "--mj-titlecolor: var(--light-grey) !important") // } // categoriesBarActive(); // topCategoriesBarScroll(); // //分类条 // function categoriesBarActive(){ // var urlinfo = window.location.pathname; // urlinfo = decodeURIComponent(urlinfo) // console.log(urlinfo); // //判断是否是首页 // if (urlinfo == '/'){ // if (document.querySelector('#category-bar')){ // document.getElementById('首页').classList.add("select") // } // }else { // // 验证是否是分类链接 // var pattern = /\/categories\/.*?\//; // var patbool = pattern.test(urlinfo); // console.log(patbool); // // 获取当前的分类 // if (patbool) { // var valuegroup = urlinfo.split("/"); // console.log(valuegroup[2]); // // 获取当前分类 // var nowCategorie = valuegroup[2]; // if (document.querySelector('#category-bar')){ // document.getElementById(nowCategorie).classList.add("select"); // } // } // } // } // /**网站提示 */ // welcome_mes(); // const aegis = new Aegis({ // id: 'YrDZ2TbYn16n2W0Yae', // 上报 id // uin: 'xxx', // 用户唯一 ID(可选) // reportApiSpeed: true, // 接口测速 // reportAssetSpeed: true, // 静态资源测速 // spa: true // spa 应用页面跳转的时候开启 pv 计算 // }); // window.onscroll = percent;// 执行函数 // //js有一个小问题:就是只要鼠标滚动不论哪里都会响应,即便你滚动的是子元素 // document.getElementById("name-container").setAttribute("style","display:none"); // var scrollFunc = function (e) { // var e = e || window.event; // if (e.wheelDelta) { // if (e.wheelDelta > 0) { // document.getElementsByClassName("menus_items")[1].setAttribute("style",""); // document.getElementById("name-container").setAttribute("style","display:none"); // } // if (e.wheelDelta < 0) { // document.getElementById("name-container").setAttribute("style",""); // document.getElementsByClassName("menus_items")[1].setAttribute("style","display:none!important"); // } // } else if (e.detail) { // if (e.detail < 0) { // document.getElementsByClassName("menus_items")[1].setAttribute("style",""); // document.getElementById("name-container").setAttribute("style","display:none"); // } // if (e.detail > 0) { // document.getElementById("name-container").setAttribute("style",""); // document.getElementsByClassName("menus_items")[1].setAttribute("style","display:none!important"); // } // } // } // window.addEventListener("DOMMouseScroll", scrollFunc) // window.addEventListener("wheel", scrollFunc) // document.getElementById("page-name").innerText=document.title.split(" | 落星屋")[0];