Anyway 主题切换

Anyway 主题免费切换

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Anyway 主题切换
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Anyway 主题免费切换
// @author       frank-xjh
// @match        https://anyway.fm/*
// @grant        none
// @require      https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    $(function(){
        var themeCss="<link rel=\"stylesheet\" href=\"https:\/\/s.anw.red\/anyway.fm\/theme.min.css\">"
        $("head").append(themeCss);
        var theme = getCookie("theme");
        if (theme != "")
        {
            $("body").removeClass("theme-default");
            $("body").addClass("theme-"+theme);
        }

        var btn="<li class=\"nav-label\"><span>主题切换(点击后请刷新)<\/span><\/li><span class=\"theme-preview-dark\"><a onclick=\"setCookie('theme','dark');\">有一点点黑<\/a><\/span><span class=\"theme-preview-eightbit\"><a onclick=\"setCookie('theme','eightbit');\">八比特复古<\/a><\/span><span class=\"theme-preview-hub\"><a onclick=\"setCookie('theme','hub');\">破嗯哈勃黄<\/a><\/span><span class=\"theme-preview-paper\"><a onclick=\"setCookie('theme','paper');\">一张旧报纸<\/a><\/span><span class=\"theme-preview-graphite\"><a onclick=\"setCookie('theme','graphite');\">平淡无奇素<\/a><\/span><span class=\"theme-preview-default\"><a onclick=\"setCookie('theme','default');\">默认红配金<\/a><\/span>";
        $("div.nav").children("ul").children().eq(12).after(btn);
    });
    function setCookie(cname,cvalue){
        document.cookie = cname+"="+cvalue+";";
    }
    function getCookie(cname){
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for(var i=0; i<ca.length; i++) {
            var c = ca[i].trim();
            if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
        }
        return "";
    }
})();