Refuse mobile page!

Redirect mobile-only URL to its corresponding PC version automatically

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name               Refuse mobile page!
// @name:zh-CN         拒绝手机版页面!
// @description        Redirect mobile-only URL to its corresponding PC version automatically
// @description:zh-CN  访问移动设备专用 URL 时跳转到对应的 PC 版页面(目前已支持微博、淘宝、天猫、京东)
// @namespace          https://github.com/xdqi/refuse-mobile-page
// @version            0.3
// @author             xdqi
// @license            MIT
// @grant              none
// @run-at             document-start
// @include            *
// ==/UserScript==

(function() {
    'use strict';

    var replaceTable = [
        // weibo.com 用户页面
        [/^http:\/\/m\.weibo\.cn\/[d|u]\/(.+)/g, 'http://weibo.com/$1'],
        // weibo.com 用户页面
        [/^http:\/\/m\.weibo\.cn\/n\/(.+)/g, 'http://weibo.com/n/$1'],
        // weibo.com 话题
        [/^http:\/\/m\.weibo\.cn\/[k]\/(.+)/g, 'http://huati.weibo.com/$1'],
        // weibo.com 微博
        [/^http:\/\/m\.weibo\.cn\/(\d+)\/([A-Za-z0-9]+)(?:\?.*)?/g, 'http://weibo.com/$1/$2'],
        // weibo.com 文章
        [/^http:\/\/media\.weibo\.cn\/article(.+)/g, 'http://weibo.com/ttarticle/p/show$1'],
        // 哔哩哔哩 视频
        [/^http:\/\/www\.bilibili\.com\/mobile\/video\/(av\d+)\.html/g, 'http://www.bilibili.com/video/$1/'],
        // 京东 产品页面
        [/^http[s]?:\/\/item\.m\.jd\.com\/product\/(\d+).html/g, 'http://item.jd.com/$1.html'],
        // 天猫 产品页面
        [/^http[s]?:\/\/detail\.m\.tmall\.com\/(.*)/g, 'http://detail.tmall.com/$1'],
        // 淘宝 产品页面
        [/^http[s]?:\/\/h5\.m\.taobao\.com\/awp\/core\/detail\.htm\?(.*)/g, 'https://item.taobao.com/item.htm?$1'],
        // 北邮人
        [/^http[s]?:\/\/m\.byr\.cn\/(.*)/g, 'https://bbs.byr.cn/#!$1'],
    ];

    var pageURL = window.location.href;
    replaceTable.forEach(function(replaceRule) {
        var newURL = pageURL.replace(replaceRule[0], replaceRule[1]);
        if (pageURL !== newURL) {
            window.location = newURL;
        }
    });

})();