吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1630|回复: 29
收起左侧

[其他原创] 【油猴脚本】娱乐项目之撒比帖子更显眼

  [复制链接]
Cristy 发表于 2025-4-7 09:48
本帖最后由 Cristy 于 2025-4-7 10:24 编辑

效果: image.png

这里可以自定义设置样式,格式是css代码:
image.png



代码上传有点问题 ,自动加了一些没用的标签,已经重新替换格式上传了:

// ==UserScript==
// @name         52pj撒币帖子更显眼
// @match        https://www.52pojie.cn/home.php?mod=space&uid=1034393
// @version      1.0
// @description  实时监测并修改链接样式
// @author       aura service
// @match        https://www.52pojie.cn/forum-10-1.html*
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @license      ISC
// ==/UserScript==

(function() {
    'use strict';

    // 默认样式配置
    const defaultStyles = {
        fontWeight: 'bold',
        color: 'red',
        fontSize: '16px'
    };

    // 获取当前样式配置
    const styles = {
        fontWeight: GM_getValue('fontWeight', defaultStyles.fontWeight),
        color: GM_getValue('color', defaultStyles.color),
        fontSize: GM_getValue('fontSize', defaultStyles.fontSize)
    };

    // 注册菜单命令以设置样式
    GM_registerMenuCommand("设置链接样式", function() {
        const newFontWeight = prompt("请输入字体粗细 (例如: bold, normal):", styles.fontWeight);
        if (newFontWeight) {
            styles.fontWeight = newFontWeight;
            GM_setValue('fontWeight', styles.fontWeight);
        }

        const newColor = prompt("请输入字体颜色 (例如: red, #ff0000):", styles.color);
        if (newColor) {
            styles.color = newColor;
            GM_setValue('color', styles.color);
        }

        const newFontSize = prompt("请输入字体大小 (例如: 16px, 1em):", styles.fontSize);
        if (newFontSize) {
            styles.fontSize = newFontSize;
            GM_setValue('fontSize', styles.fontSize);
        }

        alert("样式已更新!");
    });

    // 函数:检查并修改样式
    function checkAndModify() {
        const rows = document.querySelectorAll('tbody tr'); // 查找 tbody 下的 tr
        console.log(`找到 ${rows.length} 行`);

        rows.forEach(row => {
            const ths = row.querySelectorAll('th.common'); // 只查找 class 为 common 的 th
            let hasReward = false;

            ths.forEach(th => {
                const span = th.querySelector('span');
                if (span) {
                    console.log(`检查 th 中的 span: ${span.textContent}`);
                    if (span.textContent.includes('回帖奖励')) {
                        hasReward = true;
                        console.log('找到包含“回帖奖励”的 span');
                    }
                }
            });

            if (hasReward) {
                console.log('对该行的 class 为 common 的 a 标签进行样式修改');
                const links = row.querySelectorAll('th.common a.s.xst'); // 只选择 class 为 common 的 th 下的 a 标签
                links.forEach(link => {
                    link.style.fontWeight = styles.fontWeight;
                    link.style.color = styles.color;
                    link.style.fontSize = styles.fontSize;
                    console.log(`修改链接: ${link.textContent}`);
                });
            } else {
                console.log('该行没有包含“回帖奖励”的 span');
            }
        });
    }

    // 创建一个观察者实例
    const observer = new MutationObserver(checkAndModify);

    // 配置观察者选项
    const config = { childList: true, subtree: true };

    // 开始观察整个文档的 body
    observer.observe(document.body, config);
    console.log('开始观察整个文档的 body');

    // 初始检查
    checkAndModify();
})();

免费评分

参与人数 5吾爱币 +11 热心值 +5 收起 理由
Natu + 1 + 1 谢谢@Thanks!
52菜鸟 + 3 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
utags + 1 + 1 谢谢@Thanks!
Galwa + 1 + 1 我很赞同!
苏紫方璇 + 5 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Miko_ 发表于 2025-4-7 10:30
jacky520510 发表于 2025-4-7 09:53
叉子网址都被墙了,真是无语

https://soujiaoben.org/#/pages/list/list这个也不错

免费评分

参与人数 1吾爱币 +2 热心值 +1 收起 理由
Cristy + 2 + 1 用心讨论,共获提升!

查看全部评分

冒个泡 发表于 2025-4-7 10:09
 楼主| Cristy 发表于 2025-4-7 10:15
jacky520510 发表于 2025-4-7 09:53
叉子网址都被墙了,真是无语

国内有个 【脚本猫】 功能一样的,支持后台运行,可以试试

https://scriptcat.org/zh-CN/

免费评分

参与人数 2吾爱币 +3 热心值 +1 收起 理由
jacky520510 + 2 + 1 是个不错的脚本网站
jzyamia + 1 热心回复!

查看全部评分

jacky520510 发表于 2025-4-7 09:53
叉子网址都被墙了,真是无语
meicen2009 发表于 2025-4-7 10:00
这个挺有意思的
skl520 发表于 2025-4-7 10:02
有意思了!!!!
 楼主| Cristy 发表于 2025-4-7 10:12
冒个泡 发表于 2025-4-7 10:09
没看明白,是有回帖奖励的帖子高亮显示吗?

对,高亮显示
xin1you1di1 发表于 2025-4-7 10:20
添加后显示有点问题,无名称
 楼主| Cristy 发表于 2025-4-7 10:26
xin1you1di1 发表于 2025-4-7 10:20
添加后显示有点问题,无名称

刚才上传的时候选择了自带的代码格式,论坛编辑器自己加了一些没用的 标签,已经更新了,重新变复制试试
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-4-13 12:54

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表