// Slideshow functionality
let slideIndex = 0; // Start with the 4th slide (index 3)
showSlides(slideIndex);
// Next/previous controls
function changeSlide(n) {
showSlides(slideIndex += n);
}
// Thumbnail image controls
function currentSlide(n) {
showSlides(slideIndex = n - 1);
}
function showSlides(n) {
let i;
const slides = document.getElementsByClassName("slideshow-slide");
const dots = document.getElementsByClassName("slideshow-dot");
if (n >= slides.length) {slideIndex = 0}
if (n < 0) {slideIndex = slides.length - 1}
for (i = 0; i < slides.length; i++) {
slides[i].classList.remove("active");
}
for (i = 0; i < dots.length; i++) {
dots[i].classList.remove("active");
}
slides[slideIndex].classList.add("active");
dots[slideIndex].classList.add("active");
}
// Auto slideshow
setInterval(() => {
changeSlide(1);
}, 5000);
// Reward slideshow functionality
let rewardSlideIndex = 0;
updateRewardSlide();
function slideReward(n) {
rewardSlideIndex = (rewardSlideIndex + n + 2) % 2; // 2 is the total number of images
updateRewardSlide();
}
function currentRewardSlide(n) {
rewardSlideIndex = n;
updateRewardSlide();
}
function updateRewardSlide() {
const rewardSlideshow = document.querySelector('.reward-slideshow');
const rewardDots = document.querySelectorAll('.reward-dot');
if (rewardSlideshow) {
rewardSlideshow.style.transform = `translateX(-${rewardSlideIndex * 100}%)`;
// Update dots status
rewardDots.forEach((dot, index) => {
if (index === rewardSlideIndex) {
dot.classList.add('active');
dot.style.background = 'rgba(255,255,255,0.9)';
} else {
dot.classList.remove('active');
dot.style.background = 'rgba(255,255,255,0.5)';
}
});
}
}
// Auto rotate reward slideshow
setInterval(() => {
slideReward(1);
}, 3000);
/*
// 随机评论词(显示的跟复制出来的一样,并且重复评论词后面域名也不一样)开始
function generateConsistentRandomDomains(commentText, settings) {
const domainPositions = settings.domain_positions || [];
const repeatDisplay = settings.repeat_display || 2;
const repeatCopy = settings.repeat_copy || 2;
let displayText = '';
let copyText = '';
// 获取随机域名池(如果启用)
let domainPool = [settings.domain];
if (settings.enable_random_domains && settings.random_domains && settings.random_domains.length > 0) {
domainPool = [...settings.random_domains];
}
// 为这个评论词生成基于哈希的随机序列
const hash = simpleHash(commentText);
for (let i = 0; i < repeatDisplay; i++) {
if (i > 0) {
displayText += settings.separator || '
';
}
// 确定域名位置
const position = domainPositions[i] || 'after';
// 选择域名(基于哈希和行号)
const domainIndex = (hash + i) % domainPool.length;
const domain = domainPool[domainIndex];
// 根据位置构建文本
const lineText = position === 'before'
? domain + commentText
: commentText + domain;
displayText += lineText;
}
// 生成复制文本(可能使用不同的重复次数)
for (let i = 0; i < repeatCopy; i++) {
if (i > 0) {
copyText += settings.copy_as_text ? (settings.copy_separator || '\n') : '\n';
}
// 确定域名位置
const position = domainPositions[i] || 'after';
// 选择域名(基于哈希和行号)
const domainIndex = (hash + i) % domainPool.length;
const domain = domainPool[domainIndex];
// 根据位置构建文本
const lineText = position === 'before'
? domain + commentText
: commentText + domain;
copyText += lineText;
}
// 处理纯文本复制
if (settings.copy_as_text) {
copyText = copyText.replace(/\n/g, settings.copy_separator || '\n');
}
return {
display: displayText,
copy: copyText
};
}
// 更好的哈希函数(确保更好的随机分布)
function simpleHash(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32bit integer
}
return Math.abs(hash);
}
// 渲染评论词按钮(使用一致的随机域名)
function renderCommentButtons() {
const selectedComments = getRandomComments();
const commentContainer = document.getElementById('comment-buttons');
if (!commentContainer) return;
commentContainer.innerHTML = '';
const settings = window.commentSettings || {
domain: '347.bar',
repeat_display: 2,
repeat_copy: 2,
separator: '
',
default_color: '#1798fc',
domain_positions: ['after', 'before', 'after'],
copy_as_text: false,
copy_separator: '\n',
enable_random_domains: false
};
selectedComments.forEach(commentText => {
const commentConfig = window.commentPool.find(item => item.text === commentText);
const button = document.createElement('span');
button.className = 'keyword-btn STYLE17';
// 设置样式
const color = getCommentColor(commentConfig, settings);
const style = `style="color: ${color}; font-weight: bold;"`;
// 生成一致的随机域名组合
const result = generateConsistentRandomDomains(commentText, settings);
button.innerHTML = `${result.display}`;
// 存储复制文本到data属性
button.setAttribute('data-copy-text', result.copy);
button.setAttribute('data-comment-text', commentText);
button.onclick = function() {
const copyText = this.getAttribute('data-copy-text');
const commentText = this.getAttribute('data-comment-text');
copyCommentText(copyText, commentText);
};
commentContainer.appendChild(button);
});
}
// 随机评论词(显示的跟复制出来的一样,并且重复评论词后面域名也不一样)结束
*/
// 生成带表情的评论词文本
function generateCommentWithEmoji(commentText, domain, position, index, settings) {
const emojiSettings = window.emojiSettings || {
enabled: false,
pool: [],
positions: [],
random_position: false,
repeat_with_comment: true
};
// 如果表情功能关闭,直接返回原始评论
if (!emojiSettings.enabled || !emojiSettings.pool || emojiSettings.pool.length === 0) {
return generateCommentLine(commentText, domain, position, index);
}
// 随机选择一个表情
const randomEmoji = emojiSettings.pool[Math.floor(Math.random() * emojiSettings.pool.length)];
// 确定表情位置
let emojiPosition = emojiSettings.positions[index] || 'before';
if (emojiSettings.random_position) {
emojiPosition = Math.random() > 0.5 ? 'before' : 'after';
}
// 生成基础评论行
const baseLine = generateCommentLine(commentText, domain, position, index);
// 根据位置添加表情
if (emojiPosition === 'before') {
return randomEmoji + ' ' + baseLine;
} else {
return baseLine + ' ' + randomEmoji;
}
}
// 生成随机域名组合(每次刷新都不同)
function generateRandomDomainsPerRefresh(commentText, settings) {
const domainPositions = settings.domain_positions || [];
const repeatDisplay = settings.repeat_display || 2;
const repeatCopy = settings.repeat_copy || 2;
const emojiSettings = window.emojiSettings || {
enabled: false,
repeat_with_comment: true
};
let displayText = '';
let copyText = '';
// 获取域名(固定或随机)- 每次刷新都随机选择
let domain = settings.domain;
if (settings.enable_random_domains && settings.random_domains && settings.random_domains.length > 0) {
// 完全随机选择域名(不基于评论词哈希)
const randomIndex = Math.floor(Math.random() * settings.random_domains.length);
domain = settings.random_domains[randomIndex];
}
// 生成显示文本(根据设置决定是否显示表情)
for (let i = 0; i < repeatDisplay; i++) {
if (i > 0) {
displayText += settings.separator || '
';
}
// 显示文本默认不显示表情
const lineText = generateCommentLine(commentText, domain, domainPositions[i], i);
displayText += lineText;
}
// 生成复制文本(根据设置决定是否包含表情)
for (let i = 0; i < repeatCopy; i++) {
if (i > 0) {
copyText += settings.copy_as_text ? (settings.copy_separator || '\n') : '\n';
}
// 复制文本根据设置决定是否包含表情
let lineText;
if (emojiSettings.enabled && emojiSettings.repeat_with_comment) {
lineText = generateCommentWithEmoji(commentText, domain, domainPositions[i], i, settings);
} else if (emojiSettings.enabled && i === 0) {
// 只在第一条评论加表情
lineText = generateCommentWithEmoji(commentText, domain, domainPositions[i], i, settings);
} else {
lineText = generateCommentLine(commentText, domain, domainPositions[i], i);
}
copyText += lineText;
}
// 处理纯文本复制
if (settings.copy_as_text) {
copyText = copyText.replace(/\n/g, settings.copy_separator || '\n');
}
return {
display: displayText,
copy: copyText
};
}
// 渲染评论词按钮(使用每次刷新都不同的随机域名)
function renderCommentButtons() {
const selectedComments = getRandomComments();
const commentContainer = document.getElementById('comment-buttons');
if (!commentContainer) return;
commentContainer.innerHTML = '';
const settings = window.commentSettings || {
domain: '347.bar',
repeat_display: 2,
repeat_copy: 2,
separator: '
',
default_color: '#1798fc',
domain_positions: ['after', 'before', 'after'],
copy_as_text: false,
copy_separator: '\n',
enable_random_domains: false,
random_domain_position: true
};
const emojiSettings = window.emojiSettings || {
enabled: false,
repeat_with_comment: true
};
selectedComments.forEach(commentText => {
const commentConfig = window.commentPool.find(item => item.text === commentText);
const button = document.createElement('span');
button.className = 'keyword-btn STYLE17';
// 设置样式
const color = getCommentColor(commentConfig, settings);
const style = `style="color: ${color}; font-weight: bold;"`;
// 生成评论词
const result = generateRandomDomainsPerRefresh(commentText, settings);
button.innerHTML = `${result.display}`;
// 存储复制文本到data属性
button.setAttribute('data-copy-text', result.copy);
button.setAttribute('data-comment-text', commentText);
button.onclick = function() {
const copyText = this.getAttribute('data-copy-text');
const commentText = this.getAttribute('data-comment-text');
copyCommentText(copyText, commentText);
};
commentContainer.appendChild(button);
});
}
// 复制评论词文本
function copyCommentText(copyText, commentText = '') {
// 创建临时文本区域
const tempTextArea = document.createElement('textarea');
tempTextArea.value = copyText;
tempTextArea.style.cssText = `
position: fixed;
opacity: 0;
top: 0;
left: 0;
width: 1px;
height: 1px;
padding: 0;
border: none;
outline: none;
boxShadow: none;
background: transparent;
`;
document.body.appendChild(tempTextArea);
// 选择并复制文本
if (navigator.userAgent.match(/ipad|iphone/i)) {
tempTextArea.contentEditable = true;
tempTextArea.readOnly = false;
const range = document.createRange();
range.selectNodeContents(tempTextArea);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
tempTextArea.setSelectionRange(0, 999999);
} else {
tempTextArea.select();
}
try {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(copyText).then(() => {
showCustomToast(`"${commentText}" 已复制到剪贴板!`);
}).catch(() => {
document.execCommand('copy');
showCustomToast(`"${commentText}" 已复制到剪贴板!`);
});
} else {
const successful = document.execCommand('copy');
if (successful) {
showCustomToast(`"${commentText}" 已复制到剪贴板!`);
} else {
showCustomToast('复制失败,请手动复制', 'error');
}
}
} catch (err) {
console.error('复制失败:', err);
showCustomToast('复制失败,请手动复制', 'error');
}
document.body.removeChild(tempTextArea);
}
// 获取随机评论词
function getRandomComments() {
const settings = window.commentSettings || {
display_count: 6
};
if (!window.commentPool || window.commentPool.length === 0) {
console.error('评论词池未加载');
return ["不一样的火影", "备用评论词"];
}
// 提取所有固定评论词
const fixedComments = window.commentPool
.filter(item => item.fixed)
.map(item => item.text);
// 提取非固定评论词
const normalComments = window.commentPool
.filter(item => !item.fixed)
.map(item => item.text);
// 使用PHP配置的数量设置
const needMore = Math.max(0, settings.display_count - fixedComments.length);
// 随机选择补充的评论词
const shuffledNormals = [...normalComments].sort(() => 0.5 - Math.random());
const additionalComments = shuffledNormals.slice(0, needMore);
// 合并结果
return [...fixedComments, ...additionalComments];
}
// 初始化评论词
document.addEventListener('DOMContentLoaded', function() {
// 等待配置加载完成
if (window.commentPool && window.commentSettings) {
renderCommentButtons();
} else {
setTimeout(() => {
if (window.commentPool && window.commentSettings) {
renderCommentButtons();
} else {
console.error('评论词配置加载失败,使用默认设置');
window.commentSettings = window.commentSettings || {
display_count: 6,
domain: '347.bar',
repeat_display: 3,
repeat_copy: 3,
separator: '
',
default_color: '#1798fc',
enable_random_domains: false
};
renderCommentButtons();
}
}, 500);
}
});
/*
// 修改复制关键词函数
function copyKeyword(keyword) {
// 创建临时文本区域
const tempTextArea = document.createElement('textarea');
tempTextArea.value = keyword;
tempTextArea.style.cssText = `
position: fixed;
opacity: 0;
top: 0;
left: 0;
width: 1px;
height: 1px;
padding: 0;
border: none;
outline: none;
boxShadow: none;
background: transparent;
`;
document.body.appendChild(tempTextArea);
// 选择并复制文本
if (navigator.userAgent.match(/ipad|iphone/i)) {
// iOS设备需要特殊处理
tempTextArea.contentEditable = true;
tempTextArea.readOnly = false;
// 创建一个范围并选择文本
const range = document.createRange();
range.selectNodeContents(tempTextArea);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
tempTextArea.setSelectionRange(0, 999999);
} else {
// 其他设备
tempTextArea.select();
}
try {
// 尝试使用现代API
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(keyword).then(() => {
showCustomToast(`"${keyword}" 已复制到剪贴板!`);
}).catch(() => {
// 如果现代API失败,回退到传统方法
document.execCommand('copy');
showCustomToast(`"${keyword}" 已复制到剪贴板!`);
});
} else {
// 在不支持 navigator.clipboard 的环境中使用传统方法
const successful = document.execCommand('copy');
if (successful) {
showCustomToast(`"${keyword}" 已复制到剪贴板!`);
} else {
showCustomToast('复制失败,请手动复制', 'error');
}
}
} catch (err) {
console.error('复制失败:', err);
showCustomToast('复制失败,请手动复制', 'error');
}
// 清理临时元素
document.body.removeChild(tempTextArea);
}
// 添加触摸事件支持
// 关键词配置(可自由设置fixed属性)
const keywordPool = [
{ text: "火影同人", weight: 1000, fixed: true, color: "red" },
{ text: "张力大比拼这一块", weight: 20, fixed: false },
{ text: "火影笨子这方面", weight: 20, fixed: false },
{ text: "同人作品", weight: 20, fixed: false },
{ text: "二次元动漫", weight: 20, fixed: false },
{ text: "火影纲手雏田", weight: 20, fixed: false },
{ text: "女忍者训练师", weight: 20, fixed: false },
{ text: "火影忍者寻人启事", weight: 20, fixed: false },
{ text: "权威火影这一块", weight: 20, fixed: false },
{ text: "查克拉羁绊催泪", weight: 20, fixed: false },
{ text: "晴晴小本", weight: 20, fixed: false },
{ text: "静静宝库", weight: 20, fixed: false },
{ text: "火影同人新作", weight: 20, fixed: false },
{ text: "同人动漫", weight: 20, fixed: false },
{ text: "绝区零同人", weight: 20, fixed: false },
{ text: "小樱纲手借口寻人", weight: 20, fixed: false },
{ text: "小静本本", weight: 20, fixed: false },
{ text: "火影这一块", weight: 20, fixed: false },
];
// 智能关键词选择函数(自动识别固定关键词数量)
function getRandomKeywords() {
// 提取所有固定关键词(不限制数量)
const fixedKeywords = keywordPool
.filter(item => item.fixed)
.map(item => item.text);
// 提取非固定关键词(排除已固定的)
const normalKeywords = keywordPool
.filter(item => !item.fixed && !fixedKeywords.includes(item.text))
.map(item => item.text);
// 计算总显示数量(2-4个,至少显示所有固定关键词)
const minTotal = Math.max(6, fixedKeywords.length); // 最少显示6个关键词
const maxTotal = 6; //最多显示6个关键词
const totalCount = minTotal + Math.floor(Math.random() * (maxTotal - minTotal + 1));
// 需要补充的随机关键词数量
const needMore = Math.max(0, totalCount - fixedKeywords.length);
// 随机选择补充的关键词
const shuffledNormals = [...normalKeywords].sort(() => 0.5 - Math.random());
const additionalKeywords = shuffledNormals.slice(0, needMore);
// 合并结果
return [...fixedKeywords, ...additionalKeywords];
}
// 渲染函数
function renderKeywords() {
const selectedKeywords = getRandomKeywords();
const keywordContainer = document.querySelector('.image-container');
if (!keywordContainer) return;
// 清空容器
const existingButtons = keywordContainer.querySelectorAll('.keyword-btn.STYLE17');
existingButtons.forEach(btn => btn.remove());
// 渲染关键词
selectedKeywords.forEach((keyword, index) => {
// 查找关键词的完整配置
const keywordConfig = keywordPool.find(item => item.text === keyword);
const button = document.createElement('span');
button.className = 'keyword-btn STYLE17';
// 设置基础样式
button.style = `
margin: 10px;
display: inline-block;
`;
// 如果有设置颜色,则添加样式
const colorStyle = keywordConfig?.color ? `style="color: ${keywordConfig.color}; font-weight: bold;"` : '';
button.innerHTML = `${keyword}`;
button.onclick = () => copyKeyword(keyword);
// 换行逻辑(第2、4、6...个关键词前换行)
//if (index > 0 && index % 2 === 0) {
// keywordContainer.appendChild(document.createElement('br'));
//}
keywordContainer.appendChild(button);
});
}*/
// 复制关键词函数(使用PHP配置)
function copyKeyword(keyword) {
// 查找关键词的完整配置
const keywordConfig = window.keywordPool.find(item => item.text === keyword);
const settings = window.keywordSettings || {
default_color: '#333333'
};
// 创建临时文本区域
const tempTextArea = document.createElement('textarea');
tempTextArea.value = keyword;
tempTextArea.style.cssText = `
position: fixed;
opacity: 0;
top: 0;
left: 0;
width: 1px;
height: 1px;
padding: 0;
border: none;
outline: none;
boxShadow: none;
background: transparent;
`;
document.body.appendChild(tempTextArea);
// 选择并复制文本
if (navigator.userAgent.match(/ipad|iphone/i)) {
tempTextArea.contentEditable = true;
tempTextArea.readOnly = false;
const range = document.createRange();
range.selectNodeContents(tempTextArea);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
tempTextArea.setSelectionRange(0, 999999);
} else {
tempTextArea.select();
}
try {
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(keyword).then(() => {
showCustomToast(`"${keyword}" 已复制到剪贴板!`);
}).catch(() => {
document.execCommand('copy');
showCustomToast(`"${keyword}" 已复制到剪贴板!`);
});
} else {
const successful = document.execCommand('copy');
if (successful) {
showCustomToast(`"${keyword}" 已复制到剪贴板!`);
} else {
showCustomToast('复制失败,请手动复制', 'error');
}
}
} catch (err) {
console.error('复制失败:', err);
showCustomToast('复制失败,请手动复制', 'error');
}
document.body.removeChild(tempTextArea);
}
// 智能关键词选择函数(使用PHP配置)
function getRandomKeywords() {
const settings = window.keywordSettings || {
min_keywords: 6,
max_keywords: 6
};
if (!window.keywordPool || window.keywordPool.length === 0) {
console.error('关键词池未加载');
return ["火影同人", "备用关键词1", "备用关键词2"];
}
// 提取所有固定关键词
const fixedKeywords = window.keywordPool
.filter(item => item.fixed)
.map(item => item.text);
// 提取非固定关键词
const normalKeywords = window.keywordPool
.filter(item => !item.fixed)
.map(item => item.text);
// 使用PHP配置的数量设置
const minTotal = Math.max(settings.min_keywords, fixedKeywords.length);
const maxTotal = settings.max_keywords;
const totalCount = minTotal + Math.floor(Math.random() * (maxTotal - minTotal + 1));
// 需要补充的随机关键词数量
const needMore = Math.max(0, totalCount - fixedKeywords.length);
// 随机选择补充的关键词
const shuffledNormals = [...normalKeywords].sort(() => 0.5 - Math.random());
const additionalKeywords = shuffledNormals.slice(0, needMore);
// 合并结果
return [...fixedKeywords, ...additionalKeywords];
}
// 渲染函数(使用PHP配置)
function renderKeywords() {
const selectedKeywords = getRandomKeywords();
const keywordContainer = document.querySelector('.image-container');
if (!keywordContainer) return;
// 清空容器
keywordContainer.innerHTML = '';
const settings = window.keywordSettings || {
default_color: '#333333',
line_break_after: 0
};
// 渲染关键词
selectedKeywords.forEach((keyword, index) => {
// 查找关键词的完整配置
const keywordConfig = window.keywordPool.find(item => item.text === keyword);
const button = document.createElement('span');
button.className = 'keyword-btn STYLE17';
// 设置基础样式(保留原有的margin)
button.style.cssText = `
margin: 5px;
display: inline-block;
cursor: pointer;
`;
// 设置文字颜色(不覆盖其他样式)
const color = getKeywordColor(keywordConfig, settings);
button.innerHTML = `${keyword}`;
button.onclick = () => copyKeyword(keyword);
keywordContainer.appendChild(button);
// 换行逻辑
if (settings.line_break_after > 0 && (index + 1) % settings.line_break_after === 0) {
keywordContainer.appendChild(document.createElement('br'));
}
});
}
// 初始化关键词
document.addEventListener('DOMContentLoaded', function() {
// 等待配置加载完成
if (window.keywordPool && window.keywordSettings) {
renderKeywords();
} else {
setTimeout(() => {
if (window.keywordPool && window.keywordSettings) {
renderKeywords();
} else {
console.error('关键词配置加载失败,使用默认设置');
window.keywordSettings = window.keywordSettings || {
min_keywords: 6,
max_keywords: 6,
default_color: '#333333',
line_break_after: 0
};
renderKeywords();
}
}, 500);
}
});
// 在页面加载完成后初始化触摸支持
document.addEventListener('DOMContentLoaded', function() {
addTouchSupport();
});
// 修改显示自定义弹窗的样式,背景颜色改为白色
function showCustomToast(message, type = 'success') {
// 检查是否已存在toast,如果有则先移除
const existingToast = document.querySelector('.custom-toast');
if (existingToast) {
document.body.removeChild(existingToast);
}
// 创建toast元素
const toast = document.createElement('div');
toast.className = `custom-toast ${type}`;
// 根据设备类型调整样式
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
// 移动设备特定样式
if (isMobile) {
toast.style.cssText = `
position: fixed;
bottom: 80px; /* 调整位置避免被输入框遮挡 */
left: 50%;
transform: translateX(-50%);
background: white;
color: #333;
padding: 12px 20px;
border-radius: 8px;
z-index: 10000;
font-size: 14px;
max-width: 90%;
text-align: center;
animation: fadeInUp 0.3s ease;
box-shadow: 0 2px 10px rgba(0,0,0,0.15);
border: 1px solid #eee;
`;
}
// 设置内容
toast.innerHTML = `