Send the same topic JSON track_visit request when a linux.do topic opens in a background tab.
这个脚本只在 https://linux.do/t/* 话题页初始处于后台标签页时运行。
当页面处于后台状态时,脚本会从当前 URL 提取 topic id,并补发一条同源 GET 请求:
/t/<topic_id>/1.json?track_visit=true&forceLoad=true
请求会携带:
Discourse-Track-View: true
Discourse-Track-View-Topic-Id: <topic_id>
Discourse-Present: true
X-Requested-With: XMLHttpRequest
浏览器会通过 credentials: "include" 自动携带 linux.do 当前登录态 cookie。脚本不会读取、保存、上传或手动设置 cookie。
message-bus 请求。脚本使用 sessionStorage 按 topic id 记录当前标签页内已经触发过的请求,避免同一个标签页内重复刷新时重复补发。
仅匹配:
当前支持的话题 URL 形式包括:
https://linux.do/t/<slug>/<topic_id>
https://linux.do/t/<topic_id>/...
如果 URL 不符合支持的结构,脚本会抛出错误并停止。
本脚本为原创代码,没有复制外部代码,也没有使用 @require 外部库。
项目仓库:
https://github.com/lhish/topic_solve
Release:
https://github.com/lhish/topic_solve/releases/tag/v0.4.0
友链: