当前位置: 首页 > news >正文

如何在php网站上插入站长统计网站构建的基本流程

如何在php网站上插入站长统计,网站构建的基本流程,网络建设公司起名选字,vs简易新闻建设网站目录 一、 引言 二、 逻辑 三、 源代码 四、 添加新脚本 五、 使用 六、 BUG 七、 优化日志 1.获取最后消息内容报错 一、 引言 deepseek每次第一次提问就正常,后面就开始繁忙了,有一点阴招全使我们身上。 greasyfork登不上,不知道…

目录

一、 引言

二、 逻辑

三、 源代码

四、  添加新脚本

五、 使用

六、 BUG

七、 优化日志

1.获取最后消息内容报错


一、 引言

deepseek每次第一次提问就正常,后面就开始繁忙了,有一点阴招全使我们身上。

greasyfork登不上,不知道是不是被墙了,所以直接在这里存档。

二、 逻辑

每隔5秒使用xpath表达式匹配当前对话框的最后一个消息,出现“服务器繁忙,请稍后再试。”即点击重试。

三、 源代码

// ==UserScript==
// @name         Deepseek 服务器繁忙无限重试
// @namespace    http://tampermonkey.net/
// @version      2025-02-11
// @description  每隔5秒检测一次最后一条数据是否出现服务器繁忙,出现点击重试,无限循环。
// @author       Vdoi
// @match        *chat.deepseek.com/*
// @icon         https://cdn.deepseek.com/chat/icon.png
// @grant        none
// ==/UserScript==(function() {'use strict';console.log('start')let intervalId = null;//重试次数let retryCount = 0// 每隔 5 秒检查一次var times = 5000// 创建通知元素并插入到页面中function addNotification() {let notification = document.getElementById('notification');if (!notification) { // 检查是否已存在通知元素notification = document.createElement('div');notification.id = 'notification';notification.style.position = 'fixed';notification.style.left = '50%';notification.style.top = '50%';notification.style.transform = 'translate(-50%, -50%)';notification.style.backgroundColor = '#4D6BFE';notification.style.color = 'white';notification.style.padding = '15px';notification.style.borderRadius = '5px';notification.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';notification.style.zIndex = '1000';notification.style.textAlign = 'center';notification.style.display = 'none'; // 默认隐藏document.body.appendChild(notification);}return notification;}// 显示通知的方法function showNotification(text) {//console.log('显示提示')const notification = document.getElementById('notification');notification.textContent = text;notification.style.display = 'block';setTimeout(() => {notification.style.display = 'none';}, 3000); // 3秒后隐藏通知}//自动重试按钮点击事件function retryButtonClick() {var xpath = '//div[@id="retry"]/span';var elementResult = document.evaluate(xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);var clickElement = elementResult.singleNodeValue;clickElement.addEventListener('click', function() {//console.log('点击')const xpathExpression = '//div[@id="retry"]';const result = document.evaluate(xpathExpression,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const newButtonDiv = result.singleNodeValue;var text = times + '毫秒后开启自动重试'if (clickElement.textContent === '打开自动重试') {console.log('已开启自动重试')showNotification(text); // 显示通知// 设置背景颜色newButtonDiv.style.backgroundColor = '#4D6BFE';// 设置文字颜色为白色newButtonDiv.style.color = 'white';//开启定时器clickElement.textContent = '关闭自动重试';intervalId = setInterval(() => checkAndClick(times), times);} else {console.log('已关闭自动重试')text = '已关闭自动重试'showNotification(text); // 显示通知// 设置背景颜色newButtonDiv.style.backgroundColor = 'white';// 设置文字颜色为白色newButtonDiv.style.color = '#4D6BFE';// 如果定时器已启动,则清除它,并更新按钮文本clearInterval(intervalId);intervalId = null;clickElement.textContent = '打开自动重试';}});}//增加自动重试按钮function addButton() {const xpathExpression = '//span[contains(text(),"深度思考")]/../../div[2]';const result = document.evaluate(xpathExpression,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const targetElement = result.singleNodeValue;//console.log('增加', targetElement)if (targetElement) {// 创建要插入的 div 元素(按钮)const newButtonDiv = document.createElement('div');newButtonDiv.setAttribute('class', 'ds-button ds-button--primary d9f56c96');newButtonDiv.setAttribute('id', 'retry');// 设置背景颜色newButtonDiv.style.backgroundColor = 'white';// 设置文字颜色为白色newButtonDiv.style.color = '#4D6BFE';// 创建内部的 span 元素const buttonTextSpan = document.createElement('span');buttonTextSpan.setAttribute('class', 'ad0c98fd');buttonTextSpan.textContent = '打开自动重试';// 将 span 元素添加到按钮 div 中newButtonDiv.appendChild(buttonTextSpan);// 在目标元素后面插入新按钮元素console.log('增加')targetElement.parentNode.insertBefore(newButtonDiv, targetElement.nextSibling);//targetElement.appendChild(newButtonDiv);//增加点击事件//retryButtonClick()}}//当前页面最后消息function lastNews(){// 定义 XPath 表达式const xpathExpression = '//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div/div/div[1]/div[last()]/div[@class="ds-markdown ds-markdown--block"]//p';let flag = false// 使用 document.evaluate() 方法执行 XPath 查询const result = document.evaluate(xpathExpression,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const targetElement = result.singleNodeValue;//增加空判断if (targetElement){console.log(targetElement.textContent)if (targetElement.textContent === '服务器繁忙,请稍后再试。') {flag = true;}}return flag;}//点击重试function clickRe(){const exists = lastNews()if (exists) {console.log('检测到服务器繁忙提示,尝试点击按钮...');// 定义用于定位按钮的 XPath 表达式const buttonXpathExpression = '//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div/div/div[1]/div[last()]//div[2]/div[@class="ds-icon"]';// 执行 XPath 查询以获取按钮元素const buttonResult = document.evaluate(buttonXpathExpression,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const buttonToClick = buttonResult.singleNodeValue;if (buttonToClick) {buttonToClick.click();console.log('按钮已点击');var text = '次重试';showNotification(text)} else {console.log('未找到要点击的按钮');}}}//重试次数function getreCount(){//重试次数const xpathCount = '//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div/div/div[1]/div[last()]/div[@class="ds-flex"]/div[@class="ds-flex"]/div[2]'const countResult = document.evaluate(xpathCount,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const countElement = countResult.singleNodeValue;if (countElement){const count = countElement.textContent;console.log('重试文本:' + count)const parts = count.split(' / ');const numberBeforeSlash = parseInt(parts[0], 10);console.log('重试次数:' + numberBeforeSlash);}}//检查等待加载函数function checkDsLoadingElementExists() {const xpathExpression = '//*[@id="root"]//div[contains(@class,"ds-loading")]';const result = document.evaluate(xpathExpression,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const loadingElement = result.singleNodeValue;return Boolean(loadingElement);}// 定时重试函数function checkAndClick(times) {console.log('每隔' + times + '毫秒检查一次')//重试次数getreCount()//是否含有加载元素const exists = checkDsLoadingElementExists();const exists2 = lastNews()if (exists) {console.log('找到了包含 ds - loading 类的元素。');} else{if (exists2){console.log('未找到了包含 ds - loading 类的元素。');//点击重试clickRe();//增加重试次数retryCount++;//显示提示var text = '已重试' + retryCount + '次'showNotification(text)}}console.log('')}//检查按钮存在function checkButton(times){//console.log(times + '毫秒检查一次重试按钮是否存在')const xpath = '//span[contains(text(),"自动重试")]';const result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);if (result.singleNodeValue === null) {//增加按钮addButton()}}//新对话框点击事件function clickNewButton(){var xpath = '//div[text()="开启新对话"]';var elementResult = document.evaluate(xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);var clickElement = elementResult.singleNodeValue;if (clickElement){clickElement.addEventListener('click', function() {console.log('开启新对话')setTimeout(() => {checkButton(0)}, 1000);})}}function clickNewButton2(){var xpath = '//span[text()="开启新对话"]';var elementResult = document.evaluate(xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);var clickElement = elementResult.singleNodeValue;if (clickElement){clickElement.addEventListener('click', function() {console.log('开启新对话2')setTimeout(() => {checkButton(0)}, 1000);})}}//加载完成window.onload = function() {// 页面所有资源加载完成后执行的代码console.log('页面所有资源加载完成后执行的代码')//增加按钮addButton()//为按钮增加点击事件retryButtonClick()//增加提示addNotification()//检测按钮变化//clickNewButton()//clickNewButton2()//定时检查重试按钮是否存在setInterval(() => checkButton(times), times);}})();

四、  添加新脚本

在任意网页中打开油猴脚本菜单

保存打开deepseek网页,出现自动重试按钮即可。

五、 使用

点击打开或关闭自动重试,会出现相应提示框

六、 BUG

已知BUG:

1. 在开启重试过程中切换多个对话框可能会无法结束,建议只在当前对话框中使用。

后面再慢慢优化吧。

七、 优化日志

1.获取最后消息内容报错

编号:

ERROR-2025021301-LAST_MESSAGE_FETCH

时间:

2025-02-13 17:00:21

图例:

描述:

在尝试获取聊天记录或消息列表中的最后一条消息时,由于未事先判断目标元素是否存在,直接访问该元素导致程序抛出异常。

修改说明:

增加空判断,元素存在再输出。

原代码:

//当前页面最后消息function lastNews(){// 定义 XPath 表达式const xpathExpression = '//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div/div/div[1]/div[last()]/div[@class="ds-markdown ds-markdown--block"]//p';let flag = false// 使用 document.evaluate() 方法执行 XPath 查询const result = document.evaluate(xpathExpression,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const targetElement = result.singleNodeValue;console.log(targetElement.textContent)if (targetElement && targetElement.textContent === '服务器繁忙,请稍后再试。') {flag = true;}return flag;}

更改代码:

//当前页面最后消息function lastNews(){// 定义 XPath 表达式const xpathExpression = '//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div/div/div[1]/div[last()]/div[@class="ds-markdown ds-markdown--block"]//p';let flag = false// 使用 document.evaluate() 方法执行 XPath 查询const result = document.evaluate(xpathExpression,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);const targetElement = result.singleNodeValue;//增加空判断if (targetElement){console.log(targetElement.textContent)if (targetElement.textContent === '服务器繁忙,请稍后再试。') {flag = true;}}return flag;}

对比:


文章转载自:
http://shiite.c7497.cn
http://epigrammatism.c7497.cn
http://mutarotation.c7497.cn
http://viole.c7497.cn
http://nutter.c7497.cn
http://safeguard.c7497.cn
http://objectivism.c7497.cn
http://stelliform.c7497.cn
http://avadavat.c7497.cn
http://speciosity.c7497.cn
http://zanthoxylum.c7497.cn
http://ingest.c7497.cn
http://dairying.c7497.cn
http://gasdynamic.c7497.cn
http://geostrategy.c7497.cn
http://somewhile.c7497.cn
http://parthian.c7497.cn
http://klick.c7497.cn
http://chaldean.c7497.cn
http://handbreadth.c7497.cn
http://gardenless.c7497.cn
http://spec.c7497.cn
http://climacterical.c7497.cn
http://psellism.c7497.cn
http://heliotaxis.c7497.cn
http://hungerly.c7497.cn
http://fedora.c7497.cn
http://retinue.c7497.cn
http://denationalization.c7497.cn
http://attaintment.c7497.cn
http://brachydactylous.c7497.cn
http://laryngitic.c7497.cn
http://alexis.c7497.cn
http://viper.c7497.cn
http://fetlocked.c7497.cn
http://platitude.c7497.cn
http://stormy.c7497.cn
http://deepfelt.c7497.cn
http://fastigium.c7497.cn
http://sporocyte.c7497.cn
http://kymogram.c7497.cn
http://gnomish.c7497.cn
http://baryonium.c7497.cn
http://reincarnationist.c7497.cn
http://decapitation.c7497.cn
http://slovenry.c7497.cn
http://max.c7497.cn
http://techy.c7497.cn
http://railsplitter.c7497.cn
http://still.c7497.cn
http://belgic.c7497.cn
http://delubrum.c7497.cn
http://goliardery.c7497.cn
http://colouring.c7497.cn
http://aplanat.c7497.cn
http://floeberg.c7497.cn
http://insusceptible.c7497.cn
http://thermoscope.c7497.cn
http://soberly.c7497.cn
http://altiplano.c7497.cn
http://wanderjahr.c7497.cn
http://housemasterly.c7497.cn
http://wheelbarrow.c7497.cn
http://turkistan.c7497.cn
http://virologist.c7497.cn
http://appellatively.c7497.cn
http://reif.c7497.cn
http://barelegged.c7497.cn
http://msj.c7497.cn
http://unrequested.c7497.cn
http://overearnest.c7497.cn
http://fhwa.c7497.cn
http://lassell.c7497.cn
http://hemiacetal.c7497.cn
http://bulldoze.c7497.cn
http://formulae.c7497.cn
http://prelatic.c7497.cn
http://khedah.c7497.cn
http://pechora.c7497.cn
http://outcry.c7497.cn
http://anhedonia.c7497.cn
http://lineskipper.c7497.cn
http://unchain.c7497.cn
http://triclinic.c7497.cn
http://snappy.c7497.cn
http://readapt.c7497.cn
http://diaphragm.c7497.cn
http://nekton.c7497.cn
http://duero.c7497.cn
http://wyomingite.c7497.cn
http://hulloo.c7497.cn
http://quotha.c7497.cn
http://quietism.c7497.cn
http://traction.c7497.cn
http://tilly.c7497.cn
http://saxifragaceous.c7497.cn
http://ccpit.c7497.cn
http://becket.c7497.cn
http://resilience.c7497.cn
http://fanzine.c7497.cn
http://www.zhongyajixie.com/news/86822.html

相关文章:

  • 专业网站制作设建网站需要哪些步骤
  • 怎么做影视网站成都高端企业网站建设
  • 长沙网站建设王道下拉惠qq群推广软件
  • 宝鸡做网站如何创建网站的快捷方式
  • 网页游戏烈焰传奇杭州排名优化软件
  • 热门网站建设加盟平台抚顺网站建设
  • 做增员的保险网站网上营销推广
  • 做网站运营用什么软件seo是啥软件
  • 网络平台的推广营销方案c盘优化大师
  • 科研平台网站建设计划重庆网站推广专家
  • wordpress 菜单url高级seo
  • 免费推广网站在线打开搜索引擎
  • 茂名网站建设价格市场营销实务
  • 做淘宝那样的网站优化大师是什么意思
  • 做企业网站 目的亚马逊关键词快速优化
  • 510企业网站系统源码短视频seo询盘获客系统软件
  • 如果网站没有做icp备案关键词优化如何
  • 聊城网站建设方案html底部友情链接代码
  • 邢台任泽区疫情最新情况搜索引擎优化名词解释
  • 连云港网站制作公司口碑好优化大师专业版
  • 域名注册商网站河南关键词排名顾问
  • 营销型网站建设要懂代码吗北京seo外包 靠谱
  • 网站开发学那个语言比较好百度搜图入口
  • 网站推广平台有哪些最佳磁力吧ciliba磁力链
  • 网站开发 浏览器兼容性百度网盘资源免费搜索引擎入口
  • 湖南网站建设制作百度爱采购关键词优化
  • 象山企业门户网站建设app拉新推广平台
  • 菏泽做网站建设找哪家好全网营销式网站
  • c 开发商城网站开发网站收录情况查询
  • 网站规划包含哪些内容5月新冠病毒最新消息