Greasy Fork is available in English.
将移动网址转换为WWW网址,如果失败则恢复原始网址。
当前为
// ==UserScript==
// @name 电脑端页面
// @version 0.13
// @namespace http://greasyfork.icu/users/1171320
// @description 将移动网址转换为WWW网址,如果失败则恢复原始网址。
// @author yzcjd
// @author2 Lama AI 辅助
// @match https://m.*/*
// @run-at document-start
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// 获取当前网址
const currentUrl = window.location.href;
// 将移动网址的 "m." 替换为 "www."
const wwwUrl = currentUrl.replace('https://m.', 'https://www.');
// 尝试加载转换后的网址
fetch(wwwUrl)
.then(response => {
if (response.ok) {
// 如果转换后的网址可以访问,则跳转到新网址
window.location.href = wwwUrl;
// } else {
// 如果转换后的网址无法访问,记录在控制台并保持原网址
// console.warn(转换后的网址无法访问: ${wwwUrl});
}
})
// .catch(error => {
// 捕获任何错误并在控制台输出
// console.error(尝试转换网址时出错: ${error});
// });
})();