|
|
|
|
在键盘上按Ctrl+D即可
喜欢本站的话记得常来哦!
', function(){});};
// 返回顶部按钮点击事件
$gotop.click(function() {
$('html, body').animate({ scrollTop: 0 }, 800);
return false;
});
// 创建登录提示框
function createLoginPrompt() {
// 先移除已存在的提示框
$('.custom-alert').remove();
// 创建新提示框
var alertBox = $('
' +
'
欢迎加入我们
' +
'
请登录账号以享受更多功能
' +
'
' +
'' +
'' +
'
' +
'
');
// 添加到页面
$('body').append(alertBox);
// 设置初始位置(x:50% y:42%)
updateAlertPosition(50, 42);
// 显示提示框
alertBox.fadeIn(300);
// 登录按钮点击事件
alertBox.find('.login-btn').click(function() {
// 跳转到登录页面(请替换为实际登录页面URL)
window.location.href = '/wp-login.php';
});
// 取消按钮点击事件
alertBox.find('.cancel-btn').click(function() {
alertBox.fadeOut(300, function() {
$(this).remove();
});
});
// 点击提示框外部关闭
$(document).on('click', function(e) {
if (!$(e.target).closest('.custom-alert').length) {
alertBox.fadeOut(300, function() {
$(this).remove();
});
}
});
}
// 更新提示框位置
function updateAlertPosition(x, y) {
// 限制值在0-100之间
x = Math.max(0, Math.min(100, x));
y = Math.max(0, Math.min(100, y));
var alertBox = $('.custom-alert');
alertBox.css({
left: x + '%',
top: y + '%',
transform: 'translate(-' + x + '%, -' + y + '%)'
});
}
// 签到按钮点击事件:判断登录状态
$checkinBtn.click(function(e) {
// 判断用户是否登录(通过body是否有logged-in类,WordPress默认逻辑)
if (!$('body').hasClass('logged-in')) {
// 未登录:阻止默认行为,显示登录提示
e.preventDefault();
createLoginPrompt();
return false;
}
// 已登录:不做干预,保留原有签到逻辑
});
// 未登录时给签到按钮添加视觉提示
if (!$('body').hasClass('logged-in')) {
$checkinBtn.css({
opacity: '0.6', // 半透明
cursor: 'not-allowed' // 鼠标指针变为禁止样式
});
}
});
function smoothScrollToTop() {
if (scrollAnimationId) {
cancelAnimationFrame(scrollAnimationId);
}
const startPosition = window.pageYOffset;
const startTime = performance.now();
const duration = 800; // 动画持续时间(ms)
const animateScroll = (currentTime) => {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
// 使用缓动函数使滚动更自然
const easeProgress = easeOutCubic(progress);
window.scrollTo(0, startPosition * (1 - easeProgress));
if (progress < 1) {
scrollAnimationId = requestAnimationFrame(animateScroll);
} else {
scrollAnimationId = null;
}
};
// 缓动函数 - 平滑减速
function easeOutCubic(t) {
return (--t) * t * t + 1;
}
// 监听用户滚动中断
const handleUserScroll = () => {
if (scrollAnimationId) {
cancelAnimationFrame(scrollAnimationId);
scrollAnimationId = null;
window.removeEventListener('wheel', handleUserScroll);
window.removeEventListener('touchmove', handleUserScroll);
}
};
window.addEventListener('wheel', handleUserScroll, { passive: true });
window.addEventListener('touchmove', handleUserScroll, { passive: true });
scrollAnimationId = requestAnimationFrame(animateScroll);
}
// 保持原有功能不变
(function(a) {
a.extend({
mouseMoveShow: function(b) {
var d = 0,
c = 0,
h = 0,
k = 0,
e = 0,
f = 0;
var menu = a(b);
var isMenuShowing = false;
var isOnImage = false;
var imageUrl = '';
// 创建提示框元素
var tooltip = $('
复制成功
').css({
'position': 'absolute',
'background': 'rgba(0,0,0,0.7)',
'color': 'white',
'padding': '5px 10px',
'border-radius': '4px',
'font-size': '12px',
'opacity': '0',
'transition': 'opacity 0.3s',
'pointer-events': 'none',
'z-index': '10001'
}).appendTo('body');
// 添加CSS过渡效果
menu.css({
'transition': 'left 0.3s ease, top 0.3s ease'
});
// 检测是否在图片上
function checkIfOnImage(target) {
var imgElement = target.closest('img');
if (imgElement) {
isOnImage = true;
imageUrl = imgElement.src;
// 修改"成为邻居"为"复制图片链接"
menu.find('a[href="https://www.kcshe.com/frieds"] i')
.removeClass('fa-meh-o')
.addClass('fa-link');
menu.find('a[href="https://www.kcshe.com/frieds"] span')
.text('复制此图片');
} else {
isOnImage = false;
imageUrl = '';
// 恢复"成为邻居"
menu.find('a[href="https://www.kcshe.com/"] i')
.removeClass('fa-link')
.addClass('fa-meh-o');
menu.find('a[href="https://www.kcshe.com/"] span')
.text('成为邻居');
}
}
// 复制图片链接函数
function copyImageUrl() {
if (!isOnImage || !imageUrl) return false;
try {
var tempInput = document.createElement('input');
tempInput.value = imageUrl;
document.body.appendChild(tempInput);
tempInput.select();
var success = document.execCommand('copy');
document.body.removeChild(tempInput);
if (success) {
// 显示提示框
var menuPos = menu.offset();
tooltip.css({
'left': menuPos.left + menu.outerWidth() + 10,
'top': menuPos.top
}).stop().css('opacity', 1)
.delay(1500)
.animate({opacity: 0}, 500);
return true;
} else {
throw new Error('复制失败');
}
} catch (err) {
tooltip.text('复制失败').css({
'background': 'rgba(255,0,0,0.7)',
'left': menu.offset().left + menu.outerWidth() + 10,
'top': menu.offset().top
}).stop().css('opacity', 1)
.delay(1500)
.animate({opacity: 0}, 500);
return false;
}
}
a(window).mousemove(function(g) {
d = a(window).width();
c = a(window).height();
h = g.clientX;
k = g.clientY;
e = g.pageX;
f = g.pageY;
// 调整位置防止超出窗口
h + menu.width() >= d && (e = e - menu.width() - 5);
k + menu.height() >= c && (f = f - menu.height() - 5);
a("html").on({
contextmenu: function(c) {
if (3 == c.which) {
checkIfOnImage(c.target);
if (isMenuShowing) {
// 菜单已显示,平滑移动到新位置
menu.css({
left: e,
top: f
});
} else {
// 菜单未显示,显示菜单
menu.css({
left: e,
top: f
}).show();
isMenuShowing = true;
}
c.preventDefault(); // 阻止默认右键菜单
}
},
click: function() {
menu.hide();
isMenuShowing = false;
}
});
});
// 修改"成为邻居"的点击事件
menu.on('click', 'a[href="https://www.kcshe.com/"]', function(e) {
if (isOnImage && imageUrl) {
e.preventDefault();
copyImageUrl();
menu.hide();
isMenuShowing = false;
}
});
// 新增:滚动时隐藏菜单
a(window).scroll(function() {
menu.hide();
isMenuShowing = false;
});
},
disabledContextMenu: function() {
window.oncontextmenu = function() {
return !1
}
}
})
})(jQuery);
function getSelect() {
"" == (window.getSelection ? window.getSelection() : document.selection.createRange().text) ? layer.msg("请先选择要复制的内容!") : document.execCommand("Copy")
}
function baiduSearch() {
var a = window.getSelection ? window.getSelection() : document.selection.createRange().text;
"" == a ? layer.msg("请先选择要搜索的内容!") : window.open("https://www.kcshe.com/?s=" + a)
}
$(function() {
for (var a = navigator.userAgent, b = "Android;iPhone;SymbianOS;Windows Phone;iPad;iPod".split(";"), d = !0, c = 0; c < b.length; c++) if (0 < a.indexOf(b[c])) {
d = !1;
break
}
d && ($.mouseMoveShow(".usercm"), $.disabledContextMenu())
});
// 复制当前页面地址函数
function copyPageUrl() {
try {
var tempInput = document.createElement('input');
tempInput.value = window.location.href;
document.body.appendChild(tempInput);
tempInput.select();
var success = document.execCommand('copy');
document.body.removeChild(tempInput);
if (success) {
// 显示提示框
var menu = $('.usercm');
var tooltip = $('.copy-tooltip').text('已复制页面地址');
var menuPos = menu.offset();
tooltip.css({
'left': menuPos.left + menu.outerWidth() + 10,
'top': menuPos.top
}).stop().css('opacity', 1)
.delay(1500)
.animate({opacity: 0}, 500);
return true;
} else {
throw new Error('复制失败');
}
} catch (err) {
$('.copy-tooltip').text('复制失败').css({
'background': 'rgba(255,0,0,0.7)',
'left': $('.usercm').offset().left + $('.usercm').outerWidth() + 10,
'top': $('.usercm').offset().top
}).stop().css('opacity', 1)
.delay(1500)
.animate({opacity: 0}, 500);
return false;
}
}
');
// 添加点击事件监听器
element.addEventListener("click", function() {
// 切换 class
if (element.classList.contains("active")) {
element.classList.remove("active");
} else {
element.classList.add("active");
}
});
document.getElementById("macgf_cb_ht").addEventListener("click", function() {
// 跳转到指定网址
window.location.href = "https://www.kcshe.com/";
});
document.addEventListener("DOMContentLoaded", function() {
var divElement = document.getElementById("macgf_cb_ht");
// 获取当前页面的完整URL
var currentPageUrl = window.location.href;
// 指定的首页URL
var homepageUrl = "https://www.kcshe.com/";
// 检查当前页面是否为首页
if (currentPageUrl !== homepageUrl) {
// 如果是首页,则显示 div 元素
divElement.style.display = "block";
} else {
// 如果不是首页,则隐藏 div 元素
divElement.style.display = "none";
}
});
// 获取付费金额语音提醒用户
jQuery(document).ready(function($) {
$(document).ajaxComplete(function(event, xhr, settings) {
if(settings.data && settings.data.indexOf('action=initiate_pay') !== -1) {
var responseData = JSON.parse(xhr.responseText);
var amount = responseData.order_price;
var audioUrl = 'https://dict.youdao.com/dictvoice?audio=尊敬的用户,你本次交易金额为' + amount + '元记得不要付错了哟&le=zh';
var audio = new Audio(audioUrl);
audio.play();
}
});
});
document.addEventListener('DOMContentLoaded', function() {
const tabs = document.querySelectorAll(".tab");
const tabContents = document.querySelectorAll("#post-details, #comment-sug, #faq, #free_sponsor");
const hideElements = document.querySelectorAll('.user-card.zib-widget.author, .theme-box.relates.relates-thumb');
tabs.forEach(tab => {
tab.addEventListener("click", function() {
tabs.forEach(t => t.classList.remove("active"));
tabContents.forEach(c => c.style.display = "none");
this.classList.add("active");
const targetElement = document.querySelector(this.dataset.target);
targetElement.style.display = "block";
if (this.dataset.target === "#comment-sug") {
hideElements.forEach(element => {
element.style.display = "none";
}
);
} else {
hideElements.forEach(element => {
element.style.display = "block";
}
);
}
});
}
);
});