抹去的秋愁 发表于 2025-3-31 18:22

TM美化脚本问题

TM美化脚本无法安装

subaobao_ok 发表于 2025-3-31 18:45

本帖最后由 subaobao_ok 于 2025-3-31 18:47 编辑

@ngbanyan 可能是网络问题吧。
我这里只有这个我已经微调过的代码,不一定适合你用,主要调了字体和窄窗口宽度,其他忘了,如果需要的话可以参考一下// ==UserScript==
// @name          💡 pcbeta.com
//@namespace    pcbeta Scripts
// @version      2.0.241225.1
// @author      ngbanyan
// @description]   远景论坛简单美化
// @Icon          https://www.google.com/s2/favicons?sz=64&domain=bbs.pcbeta.com
//
// @downloadURL   https://pastebin.com/raw/VcMuuDAQ
// @updateURL   https://pastebin.com/raw/VcMuuDAQ
//
// @match         *://bbs.pcbeta.com/*
// @match         *://i.pcbeta.com/home.php?mod=task*
//
// @exclude       *://bbs.pcbeta.com/search.php*
// @exclude       *://bbs.pcbeta.com/misc.php*
//
// @grant         GM_addStyle
// ==/UserScript==

(function (__css, __replys) {
      // 根据标题判断网站状态
      if (document.title.search(/520: |504 Bad|服务器维护|网站升级/) > -1) {
                //setTimeout(() => { location.href = location.href; }, 5000);
                return;
      }

      // 检测当前网址
      const urlHas = (r) => location.href.search(r) > -1;

      // 访问任务页自动打卡
      if (urlHas(/i\.pcbeta\.com\/home\.php\?mod\=task$/)) {
                setTimeout(async () => {
                        await fetch("https://i.pcbeta.com/home.php?mod=task&do=apply&id=149");
                }, 1000);
                return;
      }

      // 不处理以下页面
      if (!urlHas(/bbs\.pcbeta\.com/) || urlHas(/mod=(?:post|mpdcp|attachment|logging|register|misc|space|rss)/)) {
                return;
      }

      // 加载自定义样式
      GM_addStyle(__css);

      // 本日签到内容生成
      const signinMsg = (new Date().getMonth() + 1 + "." + new Date().getDate() + " 每日签到打卡").replace(/\b\d\b/g, "0$&");

      // 广告过滤
      for (const el of document.querySelectorAll(".ad, .a_pt, .a_pb")) {
                el.remove();
      }

      // 列表页
      if (urlHas(/forum\-[^\-]+\-\d+\.html|forum\.php/)) {
                // 添加发贴时间链接
                const _fom = document.getElementById("filter_orderby_menu");
                if (!!_fom) {
                        const _links = _fom.innerHTML.match(/<a href="([^"]+)">发帖时间<\/a>/).replace(/&amp;/g, "&");
                        const _fdl = document.getElementById("filter_dateline");
                        const _link = createEl("a", "发帖时间&nbsp;", { href: _links, class: "xi2" });
                        _fdl.before(_link);
                }
      }

      // 内容页
      if (urlHas(/viewthread/)) {
                // 快捷插入签到内容
                const _ts = document.getElementById("thread_subject");
                if (!!_ts && _ts.textContent.includes("打卡专用")) {
                        const _btn = createEl("a", "快捷签到", { id: "post_reply", class: "pgsbtn", href: "javascript:;", style: "background-color: #0C9D0C;" });
                        const _fpm = document.getElementById("fastpostmessage");
                        const _fps = document.getElementById("fastpostsubmit");
                        _btn.addEventListener("click", () => {
                              _fpm.value = signinMsg;
                              _fps.click();
                              setTimeout(() => {
                                        location.href = "https://i.pcbeta.com/home.php?mod=task&item=doing";
                              }, 2000);
                        });
                        document.getElementById("pgt").append(_btn);
                }

                // 快捷回复
                if (Object.keys(__replys).length > 0) {
                        const _fpm = document.getElementById("fastpostmessage");
                        if (!!_fpm) {
                              let msgs = [];
                              for (let of Object.entries(__replys)) {
                                        if (title === "打卡") {
                                                msg = signinMsg;
                                        }
                                        msgs.push(`<a href="javascript:;" title="${msg}">#${title}</a>`);
                              }
                              // 防止超标
                              msgs = msgs.slice(-20).join("&nbsp;");
                              msgs = createEl("span", msgs, { class: "yx" });
                              msgs.querySelectorAll("a").forEach((el) => {
                                        el.addEventListener("click", () => {
                                                _fpm.value = el.getAttribute("title");
                                        });
                              });
                              document.querySelector(".pnpost").append(msgs);
                        }
                }

                // 帖子内容
                document.querySelectorAll('td').forEach((el) => {
                        // 提取校验码、Key
                        let _checksum = [];
                        let _keys = [];
                        el.textContent
                              .replace(/&nbsp;/g, " ")
                              .replace(/(?<=(?:MD5|SHA\-?(?:512|384|256|1)|CRC\-?(?:64|32))(?:[ ]*校验值?)?[::]*)\b({8}|{16}|{32}|{40}|{64}|{128})\b/g, function (m, m1) {
                                        _checksum.push(m1);
                              })
                              .replace(/\b(?:{5}(?:\-{5}){4})\b/g, function (m) {
                                        _keys.push(m);
                              });
                        // 修复帖子内容
                        let _html = el.innerHTML
                              // 修复 Unicode 显示
                              .replace(/(?:&|&amp;)#(\d+);?/g, function (m, m1) {
                                        return ~~m1 > 65535 ? String.fromCodePoint(m1) : String.fromCharCode(m1);
                              })
                              // 本论坛链接
                              .replace(/https?:\/\/bbs\.pcbeta\.com\/(?:forum\.php\?mod=viewthread&amp;tid=\d+(?:&amp;highlight=.+)?|viewthread\-\d+\-\d+\-\d+\.html)(?=<\/(?:font|br)| |&nbsp;)/g, (m) => `<a href="${m}" target="_blank">${m}</a>`)
                              // data:image
                              .replace(/img file="https?:\/\/data:image/g, `img src="data:image`);
                        // 校验码高亮
                        if (_checksum.length > 0) {
                              _html = _html.replace(new RegExp(`\\b(?:${_checksum.join("|")})\\b`, "g"), (m) => `<abbr title="点击复制到剪贴板" class="copyclipboard" onclick="copycode(this)">${m}</abbr>`);
                        }
                        // 序列号高亮
                        if (_keys.length > 0) {
                              _html = _html.replace(new RegExp(`\\b(?:${_keys.join("|")})\\b`, "g"), (m) => `<abbr title="点击显示并复制到剪贴板" class="keyhide" onclick="this.style.background='none';copycode(this)">${m}</abbr>`);
                        }
                        el.innerHTML = _html;
                });
      }

      // 生成节点
      function createEl(name, html, tag) {
                const template = document.createElement(name);
                if (typeof html === "string" && html.trim()) {
                        template.innerHTML = html.trim();
                }
                if (tag && typeof tag === "object" && tag !== null) {
                        for (let of Object.entries(tag)) {
                              template.setAttribute(key, value);
                        }
                }
                return template;
      }

      // 顶部用户导航悬停
      const nav = document.getElementById("toptb");
      window.onscroll = function () {
                if (document.documentElement.scrollTop > 10) {
                        nav.classList.add("sticky");
                } else {
                        nav.classList.remove("sticky");
                }
      };
})(
`/**** 常量设置 ****/
:root {
      /* 全局:左右边距 -> 固定值 */
      --sm: 200px;
      /* 全局:宽度 -> 固定值/百分比/自动计算 */
      --w: 1200px;
      --w: 95%;
      --w: calc(100vw - calc(var(--sm) * 2));
      /* 全局:最小宽度 -> 固定值 */
      --min-w: 1200px;
      /* 全局:背景色 */
      --bg: #e1e2e8;
      /* 全局:圆角宽度 */
      --br: 4px;
      /* 全局:字体 */
      --font-family: "XHei_Classical";
      /* 全局:阴影 */
      --shadow: 0 0 20px -5px rgba(51, 51, 51, 0.5);
      --shadow: 2px 2px 10px -5px rgba(31, 6, 13, 0.5);
      /* 列表:分隔栏背景色 */
      --sep-bg: #dae7f6;
      /* 列表:偶数行背景色 */
      --odd-bg: #f8f8f8;
}
/* 跟随系统的 Dark 模式,修改下面 dark1 为 dark 即可开启 */
@media (prefers-color-scheme: dark1) {
      :root {
                /* 全局:背景色 */
                --bg: #222529;
                /* 全局:阴影 */
                --shadow: none;
      }
      #nv ul li a,
      #pt .z a {
                color: #fff;
      }
      .bmw .bm_h {
                background-color: #ddd;
      }
}
/*注释掉“读后灰色”标题*/
.tl th a:visited,
.tl td a:visited {
    color: #333;
}
/* 小屏幕 */
@media screen and (max-width: 1100px) {
      :root {
                /* 全局:最小宽度 */
                --min-w: 850px;
      }
}

/**** 主体 ****/
body {
      background: var(--bg);
      background-size: cover;
      text-shadow: transparent 0px 0px 0px, rgba(0, 0, 0, 0.68) 0px 0px 0px !important;
}
/* 主体宽度 */
#scbar,
.wp {
      width: var(--w);
      min-width: var(--min-w);
      border: none;
}
/* 字体样式 */
body,
div, a, span,
table, tbody, tr, th, td,
input, select, textarea, button,
.common a.xst,
.new a.xst,
.lock a.xst {
      -webkit-text-stroke: none;

    font-family: var(--font-family);
    -webkit-text-stroke: 0.04px;

}
/* 字体大小 */
.t_f,
.common a.xst,
.new a.xst,
.lock a.xst {
      font-size: 0.9rem;
}
/* 阴影 */
#scbar,
#ct > .mn > .pbn,
#thread_types > li > a,
#newspecial,
#newspecialtmp,
#post_reply,
#post_replytmp {
      border-radius: var(--br);
      box-shadow: var(--shadow);
}
.bm.bmw,
#threadlist,
#postlist,
#f_pst {
      box-shadow: var(--shadow);
}

/* 顶部用户快捷悬停 */
#toptb {
      width: 100%;
      padding: 0;
      margin: 0;
}
.sticky {
      position: fixed;
      top: 0;
      z-index: 99;
      opacity: 0.85;
}
/* 顶部用户快捷样式 */
#um > .usernav {
      border-radius: 0 0 6px 6px;
      min-height: 32px;
      line-height: 32px;
      font-weight: 300;
      box-shadow: none;
      box-shadow: var(--shadow);
}
/* 顶部调整 */
#hd .hdc {
      min-height: 85px;
}
#nv > ul > li > a {
      font-size: 0.8rem;
      font-weight: 300;
}
/* new 标记红色 */
a.xi1 {
      animation: sharkLink 4s ease 1s infinite normal none;
}
/* 快捷回复 */
.yx a {
      color: #a00;
}

/**** 分类 ****/
div {
      box-shadow: var(--shadow);
}
#category_lk {
      box-shadow: none;
}

/**** 列表 ****/
/* 置顶和帖子列表分隔区样式 */
#separatorline tr td,
#separatorline tr th {
      background-color: var(--sep-bg);
      line-height: 20px;
}
/* 第二页开始列表顶端,多余空行隐藏 */
.emptb,
.emptb tr * {
      height: 0px;
      line-height: 0px;
      padding: 0;
      margin: 0;
}
/* 列表样式 */
tbody:nth-child(even) tr,
tbody:nth-child(odd) tr {
      background-color: var(--odd-bg);
}
/* 用户名字体 */
.by > cite > a {
      font-size: 0.65rem;
      font-weight: 400;
}

/**** 内容页 ****/
/* 楼层分隔线 */
div#postlist table {
      border-bottom: 1px solid #77b4f4;
}
/* 浏览页悬停信息样式 */
.p_pop {
      opacity: 0.85;
}
/* 发表时间、楼层 */
.plc .pi > strong > a,
em {
      font-family: Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
      background-color:#0078D7;
      border-radius: 3px;
      color: #fff;
      font-weight: 200;
      padding: 2px 6px;
      font-size: 10px;
}
/* 浏览页帖子标题样式 */
.vwthd {
      border-bottom: 1px solid #ecf1f7;
      padding-bottom: 15px;
}
h1.ts,
span#thread_subject {
      font-size: 0.9rem;
}
/* 用户名字体 */
.authi > .xw1 {
      font-size: 0.7rem;
      font-weight: 400;
}
/* abbr 样式 */
abbr {
      cursor: help;
      font-family: Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
      font-weight: 600;
      text-decoration: #61b329 dotted underline;
      text-underline-offset: 4px;
      padding: 2px 2px;
      color: #222;
}
abbr.keyhide {
      border: 1px solid #fff;
      background: #222;
}

/* 动态效果 */
@keyframes sharkLink {
      0%,
      50%,
      100% {
                opacity: 1;
      }

      25%,
      75% {
                opacity: 0.25;
      }
}
`,
// 快捷回复,最多 20 个
{
"打卡": "--",
"谢谢": "感谢楼主分享!\n          ",
"警告": "注意:\n不要发无谓信息!违者将被处罚!",
}
);:


            


Win 11 专业工作站版 ❤ 23H2 22635.5097 Bata 预览通道
百分浏览器 ❤ Cent Browser 5.1.1130.129 正式版




抹去的秋愁 发表于 2025-3-31 19:58

subaobao_ok 发表于 2025-3-31 18:45
@ngbanyan 可能是网络问题吧。
我这里只有这个我已经微调过的代码,不一定适合你用,主要调了字体和窄窗口 ...

感谢宝版,已经可用啦。

ngbanyan 发表于 2025-4-1 10:48

https://pastebin.com/raw/VcMuuDAQ
可直接访问,复制后新建脚本

抹去的秋愁 发表于 2025-4-1 13:26

ngbanyan 发表于 2025-4-1 10:48
https://pastebin.com/raw/VcMuuDAQ
可直接访问,复制后新建脚本

我在土耳其呢,这边这个链接打不开。

ngbanyan 发表于 2025-4-2 10:26

抹去的秋愁 发表于 2025-4-1 13:26
我在土耳其呢,这边这个链接打不开。

了解,我上传一个txt




抹去的秋愁 发表于 2025-4-2 14:24

ngbanyan 发表于 2025-4-2 10:26
了解,我上传一个txt

谢谢可以使用啦。
页: [1]
查看完整版本: TM美化脚本问题