Skip to content

feat: WebUI for XMOJ short messages (messages.html) + CORS proxy + userscript integration#941

Closed
Copilot wants to merge 6 commits intodevfrom
copilot/feature-webui-short-message-viewing
Closed

feat: WebUI for XMOJ short messages (messages.html) + CORS proxy + userscript integration#941
Copilot wants to merge 6 commits intodevfrom
copilot/feature-webui-short-message-viewing

Conversation

Copy link
Contributor

Copilot AI commented Mar 15, 2026

iOS/iPadOS users cannot install userscripts, making XMOJ short messages inaccessible. This adds a standalone messages.html web page with full send/receive/image support, wired into the existing userscript for seamless session hand-off.

New: messages.html

  • Split-pane layout (sidebar inbox list + thread view); mobile-slide animation
  • Login via userscript auto-fill (primary), manual PHPSESSID entry (fallback)
  • Send messages with image upload (paste or file picker); images served from api.xmoj-bbs.me
  • 10 s thread auto-refresh, 30 s background list refresh
  • Client-side rate-limit: max 5 sends / 60 s
  • Alpha badge; linked from index.html navbar and feature list

New: functions/api-proxy/[[path]].js

Cloudflare Pages Function that proxies all API POST requests server-side to api.xmoj-bbs.me, bypassing browser CORS restrictions. SSRF-guarded to only forward to the allow-listed upstream.

browser → /api-proxy/<endpoint> (same-origin) → api.xmoj-bbs.me/<endpoint>

API_BASE in messages.html is a relative /api-proxy/ path, so it works on any deployment domain without configuration.

XMOJ.user.js changes

  • Adds @match for xmoj-bbs.me/messages.html; on that domain the script exits after injecting the auto-fill only (no other features run)
  • Auto-fill: reads PHPSESSID via GM.cookie.list() (handles HttpOnly cookies) and fires xmoj-autofill-session on the page; toasts the user to log in if no session is found
  • Guards the #profile === null → loginpage.php redirect behind a hostname check so xmoj-bbs.me is never redirected
  • Fixes UtilityEnabled catch block infinite recursion (was calling itself; now returns false)
  • Replaces 4 stale assets.xmoj-bbs.me image URLs with api.xmoj-bbs.me
  • Adds missing semicolon on ServerURL declaration

Bug fixes

Bug Fix
参数DebugMode未找到 backend error Added DebugMode: false to every messages.html API POST body
UtilityEnabled stack overflow when localStorage unavailable Catch block now returns false instead of recursing
Redirect to loginpage.php on xmoj-bbs.me location.replace now gated on hostname check
Image CDN domain mismatch assets.xmoj-bbs.meapi.xmoj-bbs.me throughout
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature Request] WebUI for short message viewing</issue_title>
<issue_description>### 检查项

  • 我已确认了XMOJ增强脚本已为最新版,且最新版未实现这一功能。
  • 我已在 Issues 页面 中搜索,确认了这一提案未被提交过。

描述

Support viewing short messages without installing the userscript.

原因

Because you can't install this userscript on iOS/iPadOS</issue_description>

<agent_instructions>做一个网页,让用户输入在xmoj.tech上的账户和密码,我们去获取用户phpsessid,参照现有的script脚本从api拉取短消息并支持发送/收取/发送图片等。同时兼顾实用性和安全性和可维护性</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@boomzero ...... @PythonSmall-Q 一些问题:怎么登陆(我想到的只有用户输入PHPSESSID),系统校验 @PythonSmall-Q 但是不是所有人都知道怎么搞PHPSESSID @boomzero Maybe we just ask for the password… @boomzero And get the phpsessid ourselves @boomzero It’s actually easy because we could just copy quicksubmit’s login code @boomzero 6

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Summary by cubic

Add a web UI to read and send XMOJ short messages without the userscript, with bookmarklet/manual PHPSESSID login, image uploads, and a split‑pane chat interface; works on iOS/iPadOS. Linked from index.html with an Alpha badge and integrates with the userscript for auto-login.

  • New Features

    • Split‑pane inbox/thread/compose with Markdown, image paste/upload, click‑to‑view, and auto‑refresh; mobile slide‑back navigation.
    • Login via bookmarklet or manual PHPSESSID; no password storage. All API calls go through a same‑origin Cloudflare Pages CORS proxy (/api-proxy/) with SSRF guard and allow‑listed headers.
    • Client‑side send rate limit (5/60s) and loading/disabled states on send/login.
    • Userscript integration: auto‑fill via xmoj-autofill-session/xmoj-show-toast; userscript only scopes messages.html.
  • Bug Fixes

    • API: include DebugMode: false in POST (fixes “参数DebugMode未找到”); image URLs now use https://api.xmoj-bbs.me.
    • Userscript: prevent login redirect on xmoj-bbs.me/messages.html; read PHPSESSID from both www.xmoj.tech and 116.62.212.172; fix UtilityEnabled recursion; add missing semicolon.

Written for commit f9a8762. Summary will update on new commits.

…uto-fill

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 15, 2026

Deploying xmoj-script-dev-channel with  Cloudflare Pages  Cloudflare Pages

Latest commit: f9a8762
Status: ✅  Deploy successful!
Preview URL: https://4c8622ae.xmoj-script-dev-channel.pages.dev
Branch Preview URL: https://copilot-feature-webui-short.xmoj-script-dev-channel.pages.dev

View logs

@hendragon-bot hendragon-bot bot added the website This issue or pull request is related to website related files label Mar 15, 2026
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XMOJ 短消息</title>
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/js/bootstrap.bundle.min.js"></script>

Check failure

Code scanning / CodeQL

Untrusted domain used in script or other content High

Content loaded from untrusted domain with no integrity check.
<title>XMOJ 短消息</title>
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/marked/9.1.6/marked.min.js"></script>

Check failure

Code scanning / CodeQL

Untrusted domain used in script or other content High

Content loaded from untrusted domain with no integrity check.
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/marked/9.1.6/marked.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/dompurify/3.0.6/purify.min.js"></script>

Check failure

Code scanning / CodeQL

Untrusted domain used in script or other content High

Content loaded from untrusted domain with no integrity check.
Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
…stile, fix IP cookie check

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Copilot AI changed the title [WIP] [Feature Request] Add WebUI for viewing short messages feat: WebUI for XMOJ short messages (iOS/iPadOS support) Mar 15, 2026
Copilot AI requested a review from PythonSmall-Q March 15, 2026 08:29
…nabled recursion, semicolon

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Copilot AI changed the title feat: WebUI for XMOJ short messages (iOS/iPadOS support) feat: WebUI for XMOJ short messages (messages.html) + CORS proxy + userscript integration Mar 15, 2026
Copilot stopped work on behalf of PythonSmall-Q due to an error March 15, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL website This issue or pull request is related to website related files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants