拒绝手机版页面!

访问移动设备专用 URL 时跳转到对应的 PC 版页面(目前已支持微博、淘宝、天猫、京东)

  1. // ==UserScript==
  2. // @name Refuse mobile page!
  3. // @name:zh-CN 拒绝手机版页面!
  4. // @description Redirect mobile-only URL to its corresponding PC version automatically
  5. // @description:zh-CN 访问移动设备专用 URL 时跳转到对应的 PC 版页面(目前已支持微博、淘宝、天猫、京东)
  6. // @namespace https://github.com/xdqi/refuse-mobile-page
  7. // @version 0.3
  8. // @author xdqi
  9. // @license MIT
  10. // @grant none
  11. // @run-at document-start
  12. // @include *
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. var replaceTable = [
  19. // weibo.com 用户页面
  20. [/^http:\/\/m\.weibo\.cn\/[d|u]\/(.+)/g, 'http://weibo.com/$1'],
  21. // weibo.com 用户页面
  22. [/^http:\/\/m\.weibo\.cn\/n\/(.+)/g, 'http://weibo.com/n/$1'],
  23. // weibo.com 话题
  24. [/^http:\/\/m\.weibo\.cn\/[k]\/(.+)/g, 'http://huati.weibo.com/$1'],
  25. // weibo.com 微博
  26. [/^http:\/\/m\.weibo\.cn\/(\d+)\/([A-Za-z0-9]+)(?:\?.*)?/g, 'http://weibo.com/$1/$2'],
  27. // weibo.com 文章
  28. [/^http:\/\/media\.weibo\.cn\/article(.+)/g, 'http://weibo.com/ttarticle/p/show$1'],
  29. // 哔哩哔哩 视频
  30. [/^http:\/\/www\.bilibili\.com\/mobile\/video\/(av\d+)\.html/g, 'http://www.bilibili.com/video/$1/'],
  31. // 京东 产品页面
  32. [/^http[s]?:\/\/item\.m\.jd\.com\/product\/(\d+).html/g, 'http://item.jd.com/$1.html'],
  33. // 天猫 产品页面
  34. [/^http[s]?:\/\/detail\.m\.tmall\.com\/(.*)/g, 'http://detail.tmall.com/$1'],
  35. // 淘宝 产品页面
  36. [/^http[s]?:\/\/h5\.m\.taobao\.com\/awp\/core\/detail\.htm\?(.*)/g, 'https://item.taobao.com/item.htm?$1'],
  37. // 北邮人
  38. [/^http[s]?:\/\/m\.byr\.cn\/(.*)/g, 'https://bbs.byr.cn/#!$1'],
  39. ];
  40.  
  41. var pageURL = window.location.href;
  42. replaceTable.forEach(function(replaceRule) {
  43. var newURL = pageURL.replace(replaceRule[0], replaceRule[1]);
  44. if (pageURL !== newURL) {
  45. window.location = newURL;
  46. }
  47. });
  48.  
  49. })();
  50.