让 gemini 写了一个自动添加 tl 的 Tampermonkey 脚本,需要的朋友自取

// ==UserScript==
// @
name Reddit Auto Translate to Chinese (Simplified)
// @
name:zh-CN Reddit 自动添加中文翻译参数
// @
namespace http://tampermonkey.net/// @
version 1.1
// @
description Automatically adds 'tl=zh-hans' parameter to Reddit URLs to trigger auto-translation into Simplified Chinese.
// @
description:zh-CN 自动为
Reddit.com 域名添加 tl=zh-hans 参数,以触发网页翻译为简体中文。
// @
author Gemini
// @
match *://*.reddit.com/*
// @
grant none
// @
run-at document-start
// ==/UserScript==
(function() {
'use strict';
// 使用 URLSearchParams API 来更安全、更方便地处理 URL 参数
const params = new URLSearchParams(window.location.search);
// 检查 'tl' 参数是否已经存在且值是否为 'zh-hans'
// 如果 'tl' 参数不存在,或者存在但值不是 'zh-hans',则执行操作
if (params.get('tl') !== 'zh-hans') {
// 设置 'tl' 参数为 'zh-hans'
// 如果 'tl' 已存在,则更新其值;如果不存在,则添加
params.set('tl', 'zh-hans');
// 将更新后的参数重新应用到当前 URL 并跳转
// 这会触发页面重新加载
window.location.search = params.toString();
}
})();