Skip to content

Conversation

@GuoPCinGitHub
Copy link
Contributor

@GuoPCinGitHub GuoPCinGitHub commented Jan 5, 2026

Change selectors to fix site notice scrolling under Vector-2022.

Summary by Sourcery

错误修复:

  • 修复由于使用过期的 DOM 选择器,导致在 Vector-2022 布局下站点通知的自动滚动未生效的问题。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Fix site notice auto-scrolling not applying under the Vector-2022 layout due to outdated DOM selectors.

Change selectors to fix site notice scrolling under Vector-2022.
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 5, 2026

审阅者指南(在小型 PR 上折叠显示)

审阅者指南

调整 Vector-2022 的站点公告滚动选择器,使其针对新的容器结构,而不是旧的 body/content 布局,从而确保自动滚动依然有效,并且对自定义 moe 站点公告路径没有行为变化。

使用更新选择器后的 Vector-2022 站点公告滚动时序图

sequenceDiagram
    participant Browser
    participant Script as Vector2022Script
    participant DOM as Document

    Browser->>Script: Load Vector-2022.js
    Script->>DOM: startScroll() query
    Note right of Script: Uses selector
    Note right of Script: .vector-sitenotice-container > #siteNotice .scrollDiv:not(.scrolling)
    DOM-->>Script: NodeList of scrollDiv elements
    Script->>DOM: Add class scrolling
    Script->>DOM: Normalize children (remove empty nodes)

    Script->>Browser: setInterval(autoScroll)
    loop Every interval
        Script->>DOM: Check document.hidden
        alt Page visible
            Script->>DOM: autoScroll() query
            Note right of Script: Uses selector
            Note right of Script: .vector-sitenotice-container > #siteNotice .scrollDiv.scrolling
            DOM-->>Script: NodeList of scrolling scrollDiv elements
            Script->>DOM: Adjust scrollTop / position
        else Page hidden
            Script-->Script: Skip scrolling update
        end
    end
Loading

文件级变更

变更 详情 文件
更新 jQuery 选择器,使站点公告的滚动行为适配 Vector-2022 布局。
  • 在 startScroll 初始化函数中,将基于 body/content 的选择器前缀替换为 .vector-sitenotice-container > #siteNotice,以定位非滚动状态的 scrollDiv 元素。
  • 在 autoScroll 定时器处理函数中,对 scrollDiv.scrolling 元素应用同样的选择器前缀修改,同时保持 moe 站点公告选择器分支不变。
  • 保留现有逻辑:跳过空子节点以及加粗(font-weight: 700)的公告,仅修改 DOM 定位方式。
src/global/zh/Vector-2022.js

小贴士和命令

与 Sourcery 交互

  • 触发新的审阅: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub issue: 通过回复审阅评论,让 Sourcery 从该评论创建 issue。你也可以回复审阅评论 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文任意位置写上 @sourcery-ai summary,即可在指定位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来在任意时间(重新)生成摘要。
  • 生成审阅者指南: 在 pull request 中评论 @sourcery-ai guide,即可在任意时间(重新)生成审阅者指南。
  • 批量解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 批量忽略所有 Sourcery 审阅: 在 pull request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审阅。特别适合你想从头开始新的审阅时使用——别忘了再评论 @sourcery-ai review 来触发新的审阅!

自定义你的体验

访问你的 控制面板 来:

  • 启用或禁用审阅功能,例如 Sourcery 生成的 pull request 摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、移除或编辑自定义审阅指令。
  • 调整其他审阅设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the site notice scrolling selectors for Vector-2022 so they target the new container structure instead of the old body/content layout, ensuring auto-scrolling still works, with no behavioral changes to the custom moe sitenotice path.

Sequence diagram for Vector-2022 site notice scrolling with updated selectors

sequenceDiagram
    participant Browser
    participant Script as Vector2022Script
    participant DOM as Document

    Browser->>Script: Load Vector-2022.js
    Script->>DOM: startScroll() query
    Note right of Script: Uses selector
    Note right of Script: .vector-sitenotice-container > #siteNotice .scrollDiv:not(.scrolling)
    DOM-->>Script: NodeList of scrollDiv elements
    Script->>DOM: Add class scrolling
    Script->>DOM: Normalize children (remove empty nodes)

    Script->>Browser: setInterval(autoScroll)
    loop Every interval
        Script->>DOM: Check document.hidden
        alt Page visible
            Script->>DOM: autoScroll() query
            Note right of Script: Uses selector
            Note right of Script: .vector-sitenotice-container > #siteNotice .scrollDiv.scrolling
            DOM-->>Script: NodeList of scrolling scrollDiv elements
            Script->>DOM: Adjust scrollTop / position
        else Page hidden
            Script-->Script: Skip scrolling update
        end
    end
Loading

File-Level Changes

Change Details Files
Update jQuery selectors so site notice scroll behavior works with Vector-2022 layout.
  • Replace the body/content-based selector prefix with .vector-sitenotice-container > #siteNotice for non-scrolling scrollDiv elements in the startScroll initializer.
  • Make the same selector prefix change for scrollDiv.scrolling elements in the autoScroll interval handler, keeping the moe sitenotice selector branch unchanged.
  • Retain existing logic for skipping empty children and bold (font-weight: 700) notices, so only DOM targeting is modified.
src/global/zh/Vector-2022.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并提供了一些总体层面的反馈:

  • 更新后的 jQuery 选择器同时出现在 startScrollautoScroll 中;建议提取出公共的选择器字符串或辅助函数,这样如果未来需要修改就不会出现两处实现不一致的情况。
  • 依赖 .vector-sitenotice-container > #siteNotice 这个选择器与当前 DOM 结构高度耦合;如果可能,建议考虑使用更具弹性的选择器(例如基于一个不太可能变动的类名)以降低将来因布局更新导致的破坏风险。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- 更新后的 jQuery 选择器同时出现在 `startScroll``autoScroll` 中;建议提取出公共的选择器字符串或辅助函数,这样如果未来需要修改就不会出现两处实现不一致的情况。
- 依赖 `.vector-sitenotice-container > #siteNotice` 这个选择器与当前 DOM 结构高度耦合;如果可能,建议考虑使用更具弹性的选择器(例如基于一个不太可能变动的类名)以降低将来因布局更新导致的破坏风险。

## Individual Comments

### Comment 1
<location> `src/global/zh/Vector-2022.js:32` </location>
<code_context>
         setInterval(() => {
             if (!document.hidden) {
-                $("body > #content > #siteNotice .scrollDiv.scrolling, #moe-sitenotice-container > .moe-sitenotice .scrollDiv.scrolling").each((_, ele) => {
+                $(".vector-sitenotice-container > #siteNotice .scrollDiv.scrolling, #moe-sitenotice-container > .moe-sitenotice .scrollDiv.scrolling").each((_, ele) => {
                     const self = $(ele);
                     if (self.css("font-weight") === "700") {
</code_context>

<issue_to_address>
**suggestion:** 考虑对 `startScroll``autoScroll` 之间共享的 sitenotice 选择器进行去重。

现在 sitenotice 的选择器在 `startScroll``autoScroll` 中被重复使用,只有 `.scrollDiv` 的状态不同。可以将共享的前缀提取为一个常量(例如 `const SITE_NOTICE_SELECTOR = '.vector-sitenotice-container > #siteNotice, #moe-sitenotice-container > .moe-sitenotice';`),以保证两个调用点保持同步,并在布局变更时减少维护开销。

建议实现:

```javascript
    const SITE_NOTICE_SELECTOR = ".vector-sitenotice-container > #siteNotice, #moe-sitenotice-container > .moe-sitenotice";

    const startScroll = () => {

```

```javascript
        $(SITE_NOTICE_SELECTOR + " .scrollDiv:not(.scrolling)").addClass("scrolling").each((_, ele) => {

```

```javascript
                $(SITE_NOTICE_SELECTOR + " .scrollDiv.scrolling").each((_, ele) => {

```
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The updated jQuery selector is duplicated in both startScroll and autoScroll; consider extracting the common selector string or a helper function to avoid divergence if it needs to change again.
  • Relying on .vector-sitenotice-container > #siteNotice is fairly specific to the current DOM; if possible, consider a slightly more resilient selector (e.g., anchoring on a class that is less likely to change) to reduce future breakage from layout updates.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The updated jQuery selector is duplicated in both `startScroll` and `autoScroll`; consider extracting the common selector string or a helper function to avoid divergence if it needs to change again.
- Relying on `.vector-sitenotice-container > #siteNotice` is fairly specific to the current DOM; if possible, consider a slightly more resilient selector (e.g., anchoring on a class that is less likely to change) to reduce future breakage from layout updates.

## Individual Comments

### Comment 1
<location> `src/global/zh/Vector-2022.js:32` </location>
<code_context>
         setInterval(() => {
             if (!document.hidden) {
-                $("body > #content > #siteNotice .scrollDiv.scrolling, #moe-sitenotice-container > .moe-sitenotice .scrollDiv.scrolling").each((_, ele) => {
+                $(".vector-sitenotice-container > #siteNotice .scrollDiv.scrolling, #moe-sitenotice-container > .moe-sitenotice .scrollDiv.scrolling").each((_, ele) => {
                     const self = $(ele);
                     if (self.css("font-weight") === "700") {
</code_context>

<issue_to_address>
**suggestion:** Consider de-duplicating the sitenotice selector shared between `startScroll` and `autoScroll`.

The sitenotice selector is now repeated in both `startScroll` and `autoScroll` with only the `.scrollDiv` state differing. Extract the shared prefix into a constant (e.g. `const SITE_NOTICE_SELECTOR = '.vector-sitenotice-container > #siteNotice, #moe-sitenotice-container > .moe-sitenotice';`) to keep both call sites in sync and reduce maintenance overhead when the layout changes.

Suggested implementation:

```javascript
    const SITE_NOTICE_SELECTOR = ".vector-sitenotice-container > #siteNotice, #moe-sitenotice-container > .moe-sitenotice";

    const startScroll = () => {

```

```javascript
        $(SITE_NOTICE_SELECTOR + " .scrollDiv:not(.scrolling)").addClass("scrolling").each((_, ele) => {

```

```javascript
                $(SITE_NOTICE_SELECTOR + " .scrollDiv.scrolling").each((_, ele) => {

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@AnnAngela AnnAngela merged commit 49e5977 into MoegirlPediaInterfaceAdmins:master Jan 5, 2026
9 checks passed
@github-project-automation github-project-automation bot moved this from 🆕 待办 to ✅ 已完成 in Team backlog Jan 5, 2026
@Saoutax Saoutax added bug Something isn't working javascript Pull requests that update Javascript code labels Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working javascript Pull requests that update Javascript code

Projects

Status: 已完成

Development

Successfully merging this pull request may close these issues.

4 participants