Greasy Fork

Greasy Fork is available in English.

虾米新旧版切换

使用菜单切换新旧版虾米

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                虾米新旧版切换
// @namespace           http://www.xiami.com/
// @version             0.1
// @author              yelo <[email protected]>
// @homepage            https://gist.github.com/imyelo/98ec319fc72574f46f089777fc8a23f6
// @match               https://www.xiami.com/*
// @require             https://unpkg.com/[email protected]/src/js.cookie.js
// @grant               GM_notification
// @grant               GM_registerMenuCommand
// @description:zh-cn   使用菜单切换新旧版虾米
// @description 使用菜单切换新旧版虾米
// ==/UserScript==

(function() {
    var Cookies = window.Cookies

    var COOKIE = {
        LEGACY: {
            NAME: 'xm_expect_legacy',
            VALUE: '1',
        },
    }

    function isLegacy () {
        return Cookies.get(COOKIE.LEGACY.NAME) === COOKIE.LEGACY.VALUE
    }

    function useLegacy () {
        if (isLegacy()) {
            return
        }
        Cookies.set(COOKIE.LEGACY.NAME, COOKIE.LEGACY.VALUE)
        GM_notification('已切换至旧版虾米')
        window.location.reload()
    }

    function useLatest () {
        if (!isLegacy()) {
            return
        }
        Cookies.remove(COOKIE.LEGACY.NAME)
        GM_notification('已切换至新版虾米')
        window.location.reload()
    }

    GM_registerMenuCommand('使用旧版虾米', useLegacy)
    GM_registerMenuCommand('使用新版虾米', useLatest)
})();