$(function () { $(window).scroll(function () { let wt = $(window).scrollTop(); if (wt > $("header").height() + 200) { $(".back").fadeIn(500); } else { $(".back").fadeOut(500); } }); $(".side_bar .back").click(() => { $(window).stop().scrollTop(0); }) function toggle() { $(".common ul li").click(function () { $(this).addClass("sel").siblings().removeClass("sel"); }) } toggle(); $(window).scroll(function (e) { $(".item").each(function (i, ele) { if ($(document).scrollTop() >= $(ele).offset().top - 71) { $(".page_nav ul li").eq(i).addClass("onc").siblings().removeClass("onc"); } }) }) $(".page_nav ul li").click(function () { let current = $(".item").eq($(this).index()).offset().top - 70; $("body,html").stop().animate({ scrollTop: current }, 1) }) }) async function handleCopy(event, place = 'random', msg = '颜值20') { if (place == 'random') { function insertStringRandomly(mainStr, strToInsert) { console.log(mainStr, strToInsert); let result = []; let index = 0; let od = 0; let newStrToInsert = strToInsert.split(""); let newMainStr = mainStr.split(""); while (od <= newMainStr.length) { result.push(newMainStr[od]); if (index <= newStrToInsert.length) { if (Math.random() > 0.8) { result.push(newStrToInsert[index]); index++; } } od++; }; return result.join(''); } try { let text = window.getSelection().toString(); let newText = insertStringRandomly(text, msg); newText += " " + location.href; navigator.clipboard.writeText(newText); } catch (error) { navigator.clipboard.writeText(""); } return; } try { let text = window.getSelection().toString(); let newText = place == 'start' ? msg + text + " " + location.href : text + " " + msg + " " + location.href; navigator.clipboard.writeText(newText); } catch (error) { navigator.clipboard.writeText(""); } } //document.addEventListener('copy', handleCopy); //document.addEventListener('contextmenu', function (e) { // e.preventDefault(); //}); //document.addEventListener('keydown', function (e) { // if (e.key == 'F12') { // e.preventDefault(); // } //});