您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
一些增强功能
当前为
- // ==UserScript==
- // @name V2EX增强插件
- // @description 一些增强功能
- // @homepage https://greasyfork.org/zh-CN/scripts/3452
- // @namespace yfmx746qpx8vhhmrgzt9s4cijmejj3tn
- // @icon https://favicon.yandex.net/favicon/www.v2ex.com
- // @author me
- // @match https://*.v2ex.com/*
- // @match https://v2ex.com/*
- // @version 2025.05.03.3
- // @grant none
- // ==/UserScript==
- // 2025.05.03 按关键词屏蔽帖子中的垃圾回复。
- // 2025.04.03 签到页显示上次签到铜币数,余额页面显示签到页链接
- // 2025.04.03 各功能均改为异步执行,缩短脚本运行时间。
- // 2025.03.30 原生代码实现签到功能,去除对jQuery库的依赖
- // 2024.03.08 新消息界面,回复提醒对比感谢提醒更加醒目
- // 2024.01.16 新消息界面,显示消息序号,页码链接显示序号范围
- // 2023.12.27 避免链接转图片的大小超出布局
- // 2019.05.12 新浪的图片反防盗链
- // 2017.05.16 由于存储数据出错,改变存储数据的方式
- // 2016.05.25 链接自动转图片
- // 2016.05.21 新增召唤/呼叫管理员
- // 2016.04.12 在回复时可@所有人
- // 2015.10.16 新增在回复中标记楼主
- // 2014.01.24 初版修改版
- setTimeout(function(){
- // 签到
- setTimeout(() => {
- if (document.querySelector('a.balance_area') && document.querySelector('a[href="/settings"]')) {//已登陆
- var username = document.querySelector('a[href^="/member/"]').innerHTML;
- var today=new Date().toISOString().split("T")[0];
- var infobar = document.querySelector('#search');
- if(localStorage.signdate==today && localStorage.signuser==username && infobar){
- return;//已签到就结束
- }
- var days=0;//连续登陆天数
- //开始签到流程
- fetch("/").then(()=>{
- //document.querySelector("#search").style.fontSize="14px";
- infobar.value = "正在检测每日签到状态...";
- return fetch("/mission/daily");//继续继续,前往领取页面
- })
- .then(rsp => rsp.text()).then(data=>{
- var parser = new DOMParser();
- var doc = parser.parseFromString(data, "text/html");
- if(doc.querySelector('input[value^="领取"]')){//领取按钮存在,尝试领取
- infobar.value = "正在领取签到奖励..."
- var url=doc.querySelector('input[value^="领取"]').getAttribute('onclick').split("'")[1];
- //<input type="button" class="xxx" value="领取 X 铜币" onclick="location.href = '/mission/daily/redeem?once=12345';">
- return fetch(url)//继续继续,提交领取动作
- } else {//按钮不存在
- if (data.indexOf("已领取") != -1) {
- localStorage.signdate=today;
- localStorage.signuser=username;
- throw new Error(infobar.value = "今天已经签到了。");
- } else {
- throw new Error(infobar.value = "无法识别领取奖励按钮 :( ");
- }
- }
- })
- .then(rsp => rsp.text()).then(data=>{
- days=data.split("已连续登")[1].split(" ")[1];//连续登陆天数
- localStorage.signdate=today;
- localStorage.signuser=username;
- //若是首页,签到入口隐藏
- if(document.querySelector('a[href="/mission/daily"]')){
- document.querySelector('a[href="/mission/daily"]').parentElement.parentElement.style.display="none";
- }
- return fetch("/balance");//继续继续,查看领取数量
- })
- .then(rsp => rsp.text()).then(data=>{
- if (data.indexOf("每日登录奖励")!== -1){
- var money=data.match(/每日登录奖励 \d+ 铜币/)[0].match(/\d+/)[0];
- localStorage.signmoney=money;
- console.log(infobar.value = "连续签到" + days + "天,本次" + money + "铜币");
- } else {
- console.log(infobar.value = "未能识别到领取");
- }
- })
- .catch(error => {
- console.error("Sign info:", error);
- if(typeof error=="string" && error.indexOf("已经签到") == -1) {
- infobar.value = "请手动领取今日的登录奖励!";
- }
- });//end fetch
- }//end 判断登陆状态
- }, 0);// end 签到
- // 按关键词屏蔽帖子中的垃圾回复
- setTimeout(() => {
- if(location.pathname.indexOf("/t/")===0){
- var lowkeys = ["已 block", "已经 block"].map(key=>key.toLowerCase());
- var check = false;
- if (document.querySelector('div[id^=r_]')) {
- var replys_html = document.querySelector('div[id^=r_]').parentElement.innerHTML.toLowerCase();
- check = lowkeys.some(key => replys_html.indexOf(key) != -1)
- }
- if (check) {
- var lowcount = 0;
- document.querySelectorAll('div[id^=r_]').forEach(ele => {
- var reply_html = ele.innerHTML.toLowerCase();
- lowkeys.some(key => {
- if (reply_html.indexOf(key) != -1) {
- ele.style.display = "none";
- lowcount++;
- return true;
- }
- });
- })
- if (lowcount > 0) {
- document.querySelector('div[class="fr topic_stats"]').innerHTML += "隐藏回复 " + lowcount + " ";
- }
- }
- } // end if url
- }, 0);//end 按关键词屏蔽帖子中的垃圾回复
- //帖子标记个别没有自动标记的管理员,回复所有人
- if (location.href.indexOf("/t/") != -1) {
- setTimeout(() => {
- var modarr=["Livid","Kai","Olivia","GordianZ","sparanoid","Tink","ano"];
- var modlist="@"+modarr.join(" @");//生成@所有管理员的列表
- var uname=document.getElementById("Rightbar").getElementsByTagName("a")[0].href.split("/member/")[1];//自己用户名
- //标记管理员,预存回复用户名列表
- var lzname=document.getElementById("Main").getElementsByClassName("avatar")[0].parentNode.href.split("/member/")[1];
- var allname='@'+lzname+' ';
- var all_elem = document.querySelectorAll('a[href^="/member"].dark');
- for(var i=0; i<all_elem.length; i++) {
- if (modlist.indexOf(all_elem[i].innerHTML)!= -1){
- if (document.getElementsByClassName("badges")[i].innerHTML.indexOf("mod") == -1){
- document.getElementsByClassName("badges")[i].innerHTML+='<div class="badge mod">MOD</div>';
- }
- }
- //为回复所有人做准备
- if ( uname != all_elem[i].innerHTML && all_elem[i].href.indexOf("/member/") != -1
- && all_elem[i].innerText == all_elem[i].innerHTML && allname.indexOf('@'+all_elem[i].innerHTML+' ') == -1 ) {
- allname+='@'+ all_elem[i].innerHTML+' ';
- }
- }
- if ( document.getElementById("reply_content") ) {
- document.getElementById("reply_content").parentNode.innerHTML
- +=" <a href='javascript:;' onclick='if ( document.getElementById(\"reply_content\").value.indexOf(\""
- +allname+"\") == -1 ) {document.getElementById(\"reply_content\").value+=\"\\r\\n"+allname+"\"}'>@所有人</a>";
- if ( document.body.style.WebkitBoxShadow !== undefined ) {
- //允许调整回复框高度
- document.getElementById("reply_content").style.resize="vertical";
- }
- document.getElementById("reply_content").style.overflow="auto";
- document.getElementById("reply_content").parentNode.innerHTML
- +=" <a href='javascript:;' onclick='if ( document.getElementById(\"reply_content\").value.indexOf(\""
- +modlist+"\") == -1 ) {document.getElementById(\"reply_content\").value+=\"\\r\\n"+modlist+"\"}'>@管理员</a>";
- }
- }, 0);// end setTimeout
- }// end 回复所有人,@管理员
- // 帖子回复框增加快捷回复,提示广告贴应发在推广节点
- if (location.href.indexOf("/t/") != -1) {
- (function(){
- document.getElementById("reply_content").parentNode.innerHTML
- +=" <a href='javascript:;' onclick='document.getElementById(\"reply_content\").value+=\"\\r\\n"+"@Livid 这贴明显是推广贴,却没有发在推广节点。"+"\"'>报告广告贴</a>";
- })()
- }// end 举报广告贴链接
- // 图片链接自动转换成图片 参考caoyue@v2ex
- setTimeout(() => {
- var links = document.links;
- for (var i=0;i<links.length;i++){
- var link = links[i];
- if (/^http.*\.(?:jpg|jpeg|jpe|bmp|png|gif|webp)/i.test(link.href)
- && !/<img\s/i.test(link.innerHTML)
- && link.href.indexOf("v2ex.com/tag")==-1
- && link.href.indexOf("v2ex.com/i/")==-1){
- link.innerHTML = "<img title='" + link.href + "' src='" + link.href + "' style='max-width:98%' decoding='async' loading='lazy' />";
- // decoding='async'异步解析图像,加快显示其他内容。loading='lazy'懒加载。
- // 排除v2ex赞助者图床网页误判 例子 https://v2ex.com/i/Ve5X51qb.png
- }
- }
- }, 0);// end 图片链接自动转换成图片
- //新浪图床的图片反防盗链
- setTimeout(() => {
- Array.from(document.images).forEach(ele=>{
- if (ele.src.indexOf(".sinaimg.cn")!=-1) {
- ele.setAttribute("referrerPolicy","no-referrer");
- ele.src="https://image.baidu.com/search/down?thumburl=https://baidu.com&url="+ele.src;
- }
- })
- }, 0);// end 新浪图床的图片反防盗链
- // 在账户余额界面/明细界面的上方增加签到页面链接
- if ( location.pathname == '/balance') {
- setTimeout(() => {
- document.querySelectorAll('span[class="gray"]').forEach(ele=>{
- if(ele.parentElement.innerHTML.indexOf("当前账户余额") != -1){
- ele.parentElement.innerHTML+='<div><li class="fa fa-question-circle gray"><a href="/mission/daily" > 查看签到页面</a></li></div>'
- }
- });
- }, 0);// end setTimeout
- }
- //余额页面显示签到页面链接
- //在签到页面显示了上次领取铜币数量
- if(location.pathname == "/mission/daily" && typeof localStorage.getItem("Signmoney") == 'string'){
- setTimeout(() => {
- if(localStorage.signuser == document.querySelector('a[href^="/member/"]').innerHTML)
- document.querySelectorAll('div[class="cell"]').forEach(ele=>{
- if(ele.innerHTML.indexOf("已连续登录") == 0 ){
- ele.innerHTML += ",最近一次领取了 "+localStorage.signmoney+" 铜币。";
- }
- })
- }, 0);// end setTimeout
- }//end 签到页上次领取铜币数量
- // 新消息界面,显示消息序号,页码链接显示序号范围
- if (location.href.indexOf("/notifications") != -1){
- setTimeout(() => {
- var page_index=new URL(window.location.href).searchParams.get('p');
- var before_index=0;
- if(page_index!=null){
- before_index=(page_index-1)*50;
- }
- document.querySelectorAll("a[onclick^=delete]").forEach((ele,i)=>{
- var index_ele=document.createElement("span");
- index_ele.innerText=(i+1+before_index)+". ";
- ele.parentElement.insertBefore(index_ele,ele.parentElement.firstElementChild)
- })
- var allmsgcount=document.querySelectorAll(".header .gray")[0].innerText;//消息总数
- document.querySelectorAll(".page_current,.page_normal").forEach((ele)=>{
- var index_a=(ele.innerText-1)*50+1;
- var index_b=(ele.innerText-1)*50+50;
- var title_str=index_a+"-"+index_b;
- if(allmsgcount-index_a<50){
- title_str=index_a+"-"+allmsgcount;
- }
- ele.setAttribute("title",title_str)
- })
- }, 0);
- }// end 新消息界面,序号和翻页按钮优化
- // 新消息界面,回复提醒对比感谢提醒更加醒目
- if (location.href.indexOf("/notifications") != -1){
- setTimeout(() => {
- if(document.querySelectorAll(".payload").length > 0){
- document.querySelectorAll(".payload").forEach((ele) => {
- if(ele.parentElement.innerText.indexOf("时提到了你") != -1
- || ele.parentElement.innerText.indexOf("里回复了你") != -1 ){
- //1、被人@提醒。2、回复我的主题提醒。
- ele.style.backgroundColor="#F9EA9A";
- }
- })
- }
- }, 0);// end setTimeout
- }// end 新消息界面优化
- //清理一些这样那样的东西
- if(new Date().toISOString().split("T")[0] != localStorage.cleardate){
- setTimeout(() => {
- for (var i = localStorage.length-1; i >= 0 ; i--) {
- if(localStorage.key(i).indexOf("lscache") == 0){
- localStorage.removeItem(localStorage.key(i));
- }
- }
- if(typeof localStorage.getItem("SigninInfo") == 'string'){
- localStorage.removeItem("SigninInfo");
- }
- }, 0);// end setTimeout
- }// end 清理东西
- },0);// end