Greasy Fork

Greasy Fork is available in English.

虎扑各项细节优化

手机虎扑自动跳转网页版+清空多余参数+操作细节优化

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         虎扑各项细节优化
// @version      0.3
// @description  手机虎扑自动跳转网页版+清空多余参数+操作细节优化
// @author       233yuzi
// @match        *://bbs.hupu.com/*
// @match        *://m.hupu.com/bbs-share/*
// @icon         https://w1.hoopchina.com.cn/images/pc/old/favicon.ico
// @license MIT
// @namespace http://greasyfork.icu/users/759046
// ==/UserScript==

(function () {
    'use strict';
    console.log('启动成功')
    mobileToPc()
    openInNewWindow()

    //移动端自动跳转PC
    function mobileToPc() {
        let reg = RegExp(/bbs-share/)
        let a = location.href
        if (a.match(reg)) {
            a = a.replace("m.", "bbs.")
            a = a.replace("/bbs-share", "")
            a = a.split('?')[0]
            location.href = a
        }
    }
    //点击链接新窗口打开
    function openInNewWindow() {
        document.addEventListener('click', (e) => {
            const pattern = /my.hupu.com/
            let target = e.target
            // console.log(target.innerHTML)
            //帖子实现新标签页打开
            if (target.className === 'p-title') {
                goto(e, target.href)
            }
            //top栏实现新标签页打开
            else if (target.className === 'notificatText') {
                if (target.innerHTML === '消息') {
                    goto(e, 'https://my.hupu.com/message?tabKey=1')
                } else {
                    goto(e, 'https://my.hupu.com/personalMessage')
                }
            }
            else if (pattern.test(target.href)) {
                goto(e, target.href)
            }
        }, true)
    }
    //跳转
    function goto(e, href) {
        e.preventDefault()
        e.stopPropagation()
        window.open(href)
        return false
    }
})();