您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
匹配常见移动端常见子域(m., h5., mobile., wap., touch., 3g.)将移动网址转换为www网址,如果失败则恢复原始网址。
当前为
// ==UserScript== // @name 电脑端页面 // @version 1.2 // @namespace https://greasyfork.org/users/1171320 // @description 匹配常见移动端常见子域(m., h5., mobile., wap., touch., 3g.)将移动网址转换为www网址,如果失败则恢复原始网址。 // @author yzcjd // @author2 Lama AI 辅助 // @match *://m.*/* // @match *://h5.*/* // @match *://mobile.*/* // @match *://wap.*/* // @match *://touch.*/* // @match *://3g.*/* // @run-at document-start // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; const currentUrl = location.href; const hostname = location.hostname; // 防止跳转死循环:跳转后设置标记 if (sessionStorage.getItem('__pc_redirected__')) return; // 正则匹配常见移动子域 const mobilePrefixPattern = /^(m|h5|mobile|wap|touch|3g)\./i; if (!mobilePrefixPattern.test(hostname)) return; // 将匹配到的移动前缀替换为 www. const pcHostname = hostname.replace(mobilePrefixPattern, 'www.'); const pcUrl = currentUrl.replace(hostname, pcHostname); // 检查目标PC页面是否存在 fetch(pcUrl, { method: 'HEAD' }) .then(response => { if (response.ok) { sessionStorage.setItem('__pc_redirected__', '1'); // 设置跳转标记 window.location.href = pcUrl; // 跳转到PC版 } else { console.warn('[跳转失败] PC版返回状态:', response.status); } }) .catch(error => { console.warn('[跳转失败] 网络错误:', error); }); })();