移动版网站自动跳转到电脑版

自动将移动版网站重定向到对应的电脑版

  1. // ==UserScript==
  2. // @name 移动版网站自动跳转到电脑版
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description 自动将移动版网站重定向到对应的电脑版
  6. // @author Claude
  7. // @match *://m.thepaper.cn/*
  8. // @match *://m.huaban.com/*
  9. // @match *://m.manhuagui.com/*
  10. // @match *://m.duitang.com/*
  11. // @match *://m-2.duitang.com/*
  12. // @match *://m.douban.com/*
  13. // @match *://m.zhipin.com/*
  14. // @match *://m.jiemian.com/*
  15. // @match *://m.weibo.cn/*
  16. // @match *://m.cnbeta.com.tw/*
  17. // @match *://m.ac.qq.com/*
  18. // @match *://m.hupu.com/*
  19. // @match *://m.ximalaya.com/*
  20. // @match *://m.sohu.com/*
  21. // @match *://*.m.wikipedia.org/*
  22. // @match *://m.tianyancha.com/*
  23. // @match *://m.liepin.com/*
  24. // @match *://m.bookschina.com/*
  25. // @match *://m.dongman.la/*
  26. // @match *://m.92mh.com/*
  27. // @match *://m.dm5.com/*
  28. // @match *://m.twitch.tv/*
  29. // @match *://m.fx361.com/*
  30. // @match *://translate.ltaaa.cn/mobile/*
  31. // @match *://m.ltaaa.cn/*
  32. // @match *://m-apps.qoo-app.com/*
  33. // @grant none
  34. // @run-at document-start
  35. // @license MIT
  36. // ==/UserScript==
  37.  
  38. (function() {
  39. 'use strict';
  40. // 当前URL
  41. const currentURL = window.location.href;
  42. let desktopURL = '';
  43. // 简单替换"m."为空的网站
  44. const simpleDomains = [
  45. 'thepaper.cn',
  46. 'huaban.com',
  47. 'manhuagui.com',
  48. 'douban.com',
  49. 'zhipin.com',
  50. 'jiemian.com',
  51. 'ximalaya.com',
  52. 'sohu.com',
  53. 'tianyancha.com',
  54. 'liepin.com',
  55. 'bookschina.com',
  56. 'dongman.la',
  57. '92mh.com',
  58. 'dm5.com',
  59. 'twitch.tv',
  60. 'fx361.com'
  61. ];
  62. // 处理简单替换的情况
  63. for (const domain of simpleDomains) {
  64. if (currentURL.includes(`m.${domain}`)) {
  65. desktopURL = currentURL.replace(`m.${domain}`, domain);
  66. break;
  67. }
  68. }
  69. // 处理堆糖网不同的手机版本
  70. if (currentURL.includes('m.duitang.com')) {
  71. desktopURL = currentURL.replace('m.duitang.com', 'duitang.com');
  72. } else if (currentURL.includes('m-2.duitang.com')) {
  73. desktopURL = currentURL.replace('m-2.duitang.com', 'duitang.com');
  74. }
  75. // 处理维基百科移动版
  76. else if (currentURL.match(/([a-z]+)\.m\.wikipedia\.org/)) {
  77. const lang = currentURL.match(/([a-z]+)\.m\.wikipedia\.org/)[1];
  78. desktopURL = currentURL.replace(`${lang}.m.wikipedia.org`, `${lang}.wikipedia.org`);
  79. }
  80. // 处理龙腾网
  81. else if (currentURL.includes('translate.ltaaa.cn/mobile/article/')) {
  82. desktopURL = currentURL.replace('/mobile/article/', '/article/');
  83. }
  84. else if (currentURL.match(/m\.ltaaa\.cn\/article\/(\d+)/)) {
  85. const id = currentURL.match(/m\.ltaaa\.cn\/article\/(\d+)/)[1];
  86. desktopURL = `https://translate.ltaaa.cn/article/${id}`;
  87. }
  88. // 处理QooApp
  89. else if (currentURL.match(/m-apps\.qoo-app\.com\/([\w_]+)\/app\/(\d+)/)) {
  90. const matches = currentURL.match(/m-apps\.qoo-app\.com\/([\w_]+)\/app\/(\d+)/);
  91. const lang = matches[1];
  92. const id = matches[2];
  93. desktopURL = `https://apps.qoo-app.com/app/${id}`;
  94. }
  95. // 特殊情况处理
  96. // m.weibo.cn -> weibo.com
  97. else if (currentURL.includes('m.weibo.cn')) {
  98. desktopURL = currentURL.replace('m.weibo.cn', 'weibo.com');
  99. }
  100. // m.cnbeta.com.tw/view/XXXX.htm -> www.cnbeta.com.tw/articles/tech/XXXX.htm
  101. else if (currentURL.match(/m\.cnbeta\.com\.tw\/view\/(\d+)\.htm/)) {
  102. const id = currentURL.match(/m\.cnbeta\.com\.tw\/view\/(\d+)\.htm/)[1];
  103. desktopURL = `https://www.cnbeta.com.tw/articles/tech/${id}.htm`;
  104. }
  105. // m.ac.qq.com/chapter/index/id/XXX/cid/YYY -> ac.qq.com/ComicView/index/id/XXX/cid/YYY
  106. else if (currentURL.match(/m\.ac\.qq\.com\/chapter\/index\/id\/(\d+)\/cid\/(\d+)/)) {
  107. const matches = currentURL.match(/m\.ac\.qq\.com\/chapter\/index\/id\/(\d+)\/cid\/(\d+)/);
  108. const id = matches[1];
  109. const cid = matches[2];
  110. desktopURL = `https://ac.qq.com/ComicView/index/id/${id}/cid/${cid}`;
  111. }
  112. // m.ac.qq.com/comic/index/id/XXX -> ac.qq.com/Comic/comicInfo/id/XXX
  113. else if (currentURL.match(/m\.ac\.qq\.com\/comic\/index\/id\/(\d+)/)) {
  114. const id = currentURL.match(/m\.ac\.qq\.com\/comic\/index\/id\/(\d+)/)[1];
  115. desktopURL = `https://ac.qq.com/Comic/comicInfo/id/${id}`;
  116. }
  117. // m.hupu.com/bbs/XXX -> bbs.hupu.com/XXX.html
  118. else if (currentURL.match(/m\.hupu\.com\/bbs\/(\d+)/)) {
  119. const id = currentURL.match(/m\.hupu\.com\/bbs\/(\d+)/)[1];
  120. desktopURL = `https://bbs.hupu.com/${id}.html`;
  121. }
  122. // 如果匹配到了任何规则,执行重定向
  123. if (desktopURL) {
  124. window.location.replace(desktopURL);
  125. }
  126. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址